diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/inc/fx_api.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/inc/fx_api.h
index ae36f6b0..590688ab 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/inc/fx_api.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/inc/fx_api.h
@@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* fx_api.h PORTABLE C */
-/* 6.1.11 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -74,6 +74,12 @@
/* 04-25-2022 William E. Lamie Modified comment(s), and */
/* updated product constants, */
/* resulting in version 6.1.11 */
+/* 07-29-2022 William E. Lamie Modified comment(s), and */
+/* updated product constants, */
+/* resulting in version 6.1.12 */
+/* 10-31-2022 Xiuwen Cai Modified comment(s), and */
+/* updated product constants, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -122,8 +128,8 @@ extern "C" {
#define AZURE_RTOS_FILEX
#define FILEX_MAJOR_VERSION 6
-#define FILEX_MINOR_VERSION 1
-#define FILEX_PATCH_VERSION 11
+#define FILEX_MINOR_VERSION 2
+#define FILEX_PATCH_VERSION 0
/* Define the following symbols for backward compatibility */
#define EL_PRODUCT_FILEX
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_directory_free_search.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_directory_free_search.c
index 32833fac..934ef88a 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_directory_free_search.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_directory_free_search.c
@@ -39,7 +39,7 @@
/* FUNCTION RELEASE */
/* */
/* _fx_directory_free_search PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -82,6 +82,10 @@
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 William E. Lamie Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Bhupendra Naphade Modified comment(s), */
+/* updated available cluster */
+/* check for sub directory, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _fx_directory_free_search(FX_MEDIA *media_ptr, FX_DIR_ENTRY *directory_ptr, FX_DIR_ENTRY *entry_ptr)
@@ -434,7 +438,7 @@ FX_INT_SAVE_AREA
/* Not enough empty entries were found. If the specified directory is a sub-directory,
attempt to allocate another cluster to it. */
- if (((search_dir_ptr) || (media_ptr -> fx_media_32_bit_FAT)) && (media_ptr -> fx_media_available_clusters > clusters_needed))
+ if (((search_dir_ptr) || (media_ptr -> fx_media_32_bit_FAT)) && (media_ptr -> fx_media_available_clusters >= clusters_needed))
{
/* Search for the additional clusters we need. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_apply_logs.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_apply_logs.c
index e9df0006..d335d9f7 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_apply_logs.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_apply_logs.c
@@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _fx_fault_tolerant_apply_logs PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -81,6 +81,9 @@
/* 09-30-2020 William E. Lamie Modified comment(s), verified */
/* memcpy usage, */
/* resulting in version 6.1 */
+/* 10-31-2022 Tiejun Zhou Modified comment(s), fixed */
+/* overflow in log size check, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _fx_fault_tolerant_apply_logs(FX_MEDIA *media_ptr)
@@ -215,7 +218,7 @@ ULONG tail_cluster;
copy_size = log_len - FX_FAULT_TOLERANT_DIR_LOG_ENTRY_SIZE;
- if ((copy_offset + copy_size) > media_ptr -> fx_media_memory_size)
+ if (((ULONG64)copy_offset + (ULONG64)copy_size) > (ULONG64)(media_ptr -> fx_media_memory_size))
{
return(FX_FILE_CORRUPT);
}
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_cleanup_FAT_chain.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_cleanup_FAT_chain.c
index 92cb001c..70a7cb4c 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_cleanup_FAT_chain.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_cleanup_FAT_chain.c
@@ -29,12 +29,94 @@
#ifdef FX_ENABLE_FAULT_TOLERANT
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _fx_utility_FAT_entry_multiple_sectors_check PORTABLE C */
+/* 6.2.0 */
+/* AUTHOR */
+/* */
+/* Tiejun Zhou, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function checks whether the FAT entry spans multiple sectors. */
+/* It is only possible when the file system is FAT12. */
+/* */
+/* INPUT */
+/* */
+/* media_ptr Media control block pointer */
+/* cluster Cluster entry number */
+/* */
+/* OUTPUT */
+/* */
+/* FX_TRUE FAT entry spans two sectors */
+/* FX_FALSE FAT entry in one sector */
+/* */
+/* CALLS */
+/* */
+/* None */
+/* */
+/* CALLED BY */
+/* */
+/* _fx_fault_tolerant_cleanup_FAT_chain */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 10-31-2022 Tiejun Zhou Initial Version 6.2.0 */
+/* */
+/**************************************************************************/
+static UINT _fx_utility_FAT_entry_multiple_sectors_check(FX_MEDIA *media_ptr, ULONG cluster)
+{
+ULONG byte_offset;
+ULONG FAT_sector;
+
+ /* Check FAT format. */
+ if (!media_ptr -> fx_media_12_bit_FAT)
+ {
+
+ /* Not FAT12. The FAT entry will be in one sector. */
+ return(FX_FALSE);
+ }
+
+ /* File system is FAT12. */
+ /* Calculate the byte offset to the cluster entry. */
+ byte_offset = (((ULONG)cluster << 1) + cluster) >> 1;
+
+ /* Calculate the FAT sector the requested FAT entry resides in. */
+ FAT_sector = (byte_offset / media_ptr -> fx_media_bytes_per_sector) +
+ (ULONG)media_ptr -> fx_media_reserved_sectors;
+
+ /* Now calculate the byte offset into this FAT sector. */
+ byte_offset = byte_offset -
+ ((FAT_sector - (ULONG)media_ptr -> fx_media_reserved_sectors) *
+ media_ptr -> fx_media_bytes_per_sector);
+
+ /* Determine if we are now past the end of the FAT buffer in memory. */
+ if (byte_offset == (ULONG)(media_ptr -> fx_media_bytes_per_sector - 1))
+ {
+
+ /* Yes, we are past the end of the FAT buffer. */
+ return(FX_TRUE);
+ }
+ else
+ {
+
+ /* No, we are not past the end of the FAT buffer. */
+ return(FX_FALSE);
+ }
+}
+
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _fx_fault_tolerant_cleanup_FAT_chain PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -72,6 +154,8 @@
/* _fx_utility_FAT_flush Flush written FAT entries */
/* _fx_fault_tolerant_calculate_checksum Compute Checksum of data */
/* _fx_fault_tolerant_write_log_file Write log file */
+/* _fx_utility_FAT_entry_multiple_sectors_check */
+/* Check sectors for FAT entry */
/* */
/* CALLED BY */
/* */
@@ -85,6 +169,10 @@
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 William E. Lamie Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Tiejun Zhou Modified comment(s), */
+/* fixed FAT entry span two */
+/* sectors for FAT12, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _fx_fault_tolerant_cleanup_FAT_chain(FX_MEDIA *media_ptr, UINT operation)
@@ -123,7 +211,7 @@ ULONG last_FAT_sector;
/* At this point, the head_cluster points to the cluster chain that is to be removed. */
- /* Tail cluster points to the back of the origianl FAT chain where the new chain is attached to.
+ /* Tail cluster points to the back of the origianal FAT chain where the new chain is attached to.
The remove process terminates once this cluster is encountered. */
tail_cluster = _fx_utility_32_unsigned_read((UCHAR *)&FAT_chain -> fx_fault_tolerant_FAT_chain_insertion_back);
@@ -133,7 +221,7 @@ ULONG last_FAT_sector;
return(FX_SUCCESS);
}
- /* To opimize the deletion process of a long FAT chain, the deletion is done in sessions. During one session,
+ /* To optimize the deletion process of a long FAT chain, the deletion is done in sessions. During one session,
a set of FAT entries are removed. If one session is interrupted, after restart the deletion process resumes and
picks up from where it left.
@@ -173,6 +261,16 @@ ULONG last_FAT_sector;
/* Cache the FAT list. */
cache_ptr[cache_count++] = current_cluster;
+ /* Check whether FAT entry spans multiple sectors. */
+ if (_fx_utility_FAT_entry_multiple_sectors_check(media_ptr, current_cluster))
+ {
+ if (head_cluster == next_session || next_session == FX_FREE_CLUSTER)
+ {
+ next_session = next_cluster;
+ }
+ break;
+ }
+
/* Move to next cluster. */
current_cluster = next_cluster;
} while ((next_cluster >= FX_FAT_ENTRY_START) &&
@@ -288,5 +386,4 @@ ULONG last_FAT_sector;
return(FX_SUCCESS);
}
-#endif /* FX_ENABLE_FAULT_TOLERANT */
-
+#endif /* FX_ENABLE_FAULT_TOLERANT */
\ No newline at end of file
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_enable.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_enable.c
index f229ad9c..ce6d8a89 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_enable.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_enable.c
@@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _fx_fault_tolerant_enable PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -46,7 +46,7 @@
/* previous write operation failed, and appropriate action now must */
/* be taken to restore the integrity of the file system. Once the */
/* recovery effort is completed, the file system is properly restored. */
-/* An empty log file indicates the previous write operaiton was */
+/* An empty log file indicates the previous write operation was */
/* successfully completed and no action needs to be taken at this */
/* point. If the file system does not have a log file, or the */
/* checksum is not valid, it is an indication either the file system */
@@ -86,6 +86,10 @@
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 William E. Lamie Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Tiejun Zhou Modified comment(s), */
+/* fixed memory buffer when */
+/* cache is disabled, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _fx_fault_tolerant_enable(FX_MEDIA *media_ptr, VOID *memory_buffer, UINT memory_size)
@@ -143,11 +147,13 @@ ULONG bytes_per_cluster;
values of zero, endian issues are not important. */
/* Force update the available cluster. */
+#ifndef FX_DISABLE_CACHE
/* Invalidate the current logical sector cache. */
_fx_utility_logical_sector_flush(media_ptr, ((ULONG64) 1), (ULONG64) (media_ptr -> fx_media_total_sectors), FX_TRUE);
/* Reset the memory pointer. */
media_ptr -> fx_media_memory_buffer = media_ptr -> fx_media_sector_cache[0].fx_cached_sector_memory_buffer;
+#endif /* FX_DISABLE_CACHE */
/* Reset the available cluster. */
media_ptr -> fx_media_available_clusters = 0;
@@ -155,6 +161,7 @@ ULONG bytes_per_cluster;
/* Loop through all FAT sectors in the primary FAT. The first two entries are
examined in this loop, but they are always unavailable. */
cluster_number = 0;
+#ifndef FX_DISABLE_CACHE
for (i = 0; i < media_ptr -> fx_media_sectors_per_FAT; i = i + media_ptr -> fx_media_sector_cache_size)
{
@@ -169,6 +176,18 @@ ULONG bytes_per_cluster;
{
FAT_read_sectors = media_ptr -> fx_media_sector_cache_size;
}
+#else
+ /* Reset the buffer sector. */
+ media_ptr -> fx_media_memory_buffer_sector = (ULONG64)-1;
+ for (i = 0; i < media_ptr -> fx_media_sectors_per_FAT; i++)
+ {
+
+ /* Calculate the starting next FAT sector. */
+ FAT_sector = media_ptr -> fx_media_reserved_sectors + i;
+
+ /* Calculate how many sectors to read. */
+ FAT_read_sectors = 1;
+#endif /* FX_DISABLE_CACHE */
/* Read the FAT sectors directly from the driver. */
media_ptr -> fx_media_driver_request = FX_DRIVER_READ;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_media_open.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_media_open.c
index 183d6158..da33b465 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_media_open.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_media_open.c
@@ -36,7 +36,7 @@
/* FUNCTION RELEASE */
/* */
/* _fx_media_open PORTABLE C */
-/* 6.1.10 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -132,6 +132,10 @@
/* 01-31-2022 William E. Lamie Modified comment(s), fixed */
/* errors without cache, */
/* resulting in version 6.1.10 */
+/* 10-31-2022 Tiejun Zhou Modified comment(s), */
+/* fixed memory buffer when */
+/* cache is disabled, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _fx_media_open(FX_MEDIA *media_ptr, CHAR *media_name,
@@ -340,13 +344,8 @@ FX_INT_SAVE_AREA
/* Pickup the additional info sector number. This will only be used in FAT32 situations. */
additional_info_sector = _fx_utility_16_unsigned_read(&media_ptr -> fx_media_driver_buffer[48]);
-#ifndef FX_DISABLE_CACHE
- /* Determine how many logical sectors can be cached with user's supplied
- buffer area - there must be at least enough for one sector! */
- media_ptr -> fx_media_sector_cache_size = memory_size / media_ptr -> fx_media_bytes_per_sector;
-
/* Is there at least one? */
- if (media_ptr -> fx_media_sector_cache_size == 0)
+ if (memory_size < media_ptr -> fx_media_bytes_per_sector)
{
/* Build the "uninitialize" I/O driver request. */
@@ -363,6 +362,11 @@ FX_INT_SAVE_AREA
return(FX_BUFFER_ERROR);
}
+#ifndef FX_DISABLE_CACHE
+ /* Determine how many logical sectors can be cached with user's supplied
+ buffer area - there must be at least enough for one sector! */
+ media_ptr -> fx_media_sector_cache_size = memory_size / media_ptr -> fx_media_bytes_per_sector;
+
/* If trace is enabled, register this object. */
FX_TRACE_OBJECT_REGISTER(FX_TRACE_OBJECT_TYPE_MEDIA, media_ptr, media_name, FX_MAX_FAT_CACHE, media_ptr -> fx_media_sector_cache_size)
@@ -654,6 +658,7 @@ FX_INT_SAVE_AREA
(media_ptr -> fx_media_sector_cache_list_ptr) -> fx_cached_sector_valid = FX_FALSE;
#else
buffer_ptr = media_ptr -> fx_media_memory_buffer;
+ media_ptr -> fx_media_memory_buffer_sector = (ULONG64)-1;
#endif /* FX_DISABLE_CACHE */
/* Read the FAT32 additional information sector from the device. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_partition_offset_calculate.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_partition_offset_calculate.c
index 1f28693b..2cb2f391 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_partition_offset_calculate.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_partition_offset_calculate.c
@@ -37,6 +37,22 @@ typedef struct FX_MEDIA_PARTITION_STRUCT
ULONG fx_media_part_size;
} FX_MEDIA_PARTITION;
+/* Define internal partition constants. */
+
+#ifndef FX_MAX_PARTITION_COUNT
+#define FX_MAX_PARTITION_COUNT 16
+#endif /* FX_MAX_PARTITION_COUNT */
+
+#define FX_PARTITION_TABLE_OFFSET 446
+#define FX_PARTITION_ENTRY_SIZE 16
+#define FX_PARTITION_TYPE_OFFSET 4
+#define FX_PARTITION_LBA_OFFSET 8
+#define FX_PARTITION_SECTORS_OFFSET 12
+
+#define FX_PARTITION_TYPE_FREE 0x00
+#define FX_PARTITION_TYPE_EXTENDED 0x05
+#define FX_PARTITION_TYPE_EXTENDED_LBA 0x0F
+
/* Define function prototypes for the partition table parsing application
utility. */
@@ -45,7 +61,8 @@ UINT _fx_partition_offset_calculate(void *partition_sector, UINT partition,
ULONG *partition_start, ULONG *partition_size);
UINT _fx_utility_partition_get(FX_MEDIA_PARTITION *partition_table,
UINT *count, ULONG sector, UCHAR *sector_buffer);
-
+UINT _fx_partition_offset_calculate_extended(FX_MEDIA *media_ptr, void *partition_sector, UINT partition,
+ ULONG *partition_start, ULONG *partition_size);
/**************************************************************************/
/* */
@@ -343,3 +360,324 @@ ULONG base_sector, value;
return(FX_SUCCESS);
}
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _fx_partition_offset_calculate_extended PORTABLE C */
+/* 6.2.0 */
+/* AUTHOR */
+/* */
+/* Xiuwen Cai, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function calculates the sector offset to the specified */
+/* partition. The buffer containing the partition table is also */
+/* supplied to this function. If the buffer supplied is a boot */
+/* record (which could be the case in non-partition systems), this */
+/* function returns an offset of zero, the total sectors, and a */
+/* successful status indicating that the buffer supplied is the boot */
+/* record. Otherwise, if a partition is found, this function returns */
+/* the sector offset to its boot record along with a successful */
+/* status. If the specified partition is not found or the buffer is */
+/* not a partition table or boot record, this function returns an */
+/* error. */
+/* */
+/* Note: Empty partitions have a FX_NOT_FOUND return code. */
+/* Use partition index 0 to 3 for primary partition and index 4 to */
+/* FX_MAX_PARTITION_COUNT for extended partition. */
+/* */
+/* INPUT */
+/* */
+/* media_ptr Media control block pointer */
+/* partition_sector Pointer to buffer containing */
+/* either the partition table */
+/* or the boot sector */
+/* partition Desired partition */
+/* partition_start Return partition start */
+/* partition_size Return partition size */
+/* */
+/* OUTPUT */
+/* */
+/* return status */
+/* */
+/* CALLS */
+/* */
+/* _fx_utility_16_unsigned_read Read a USHORT from memory */
+/* _fx_utility_32_unsigned_read Read a ULONG from memory */
+/* _fx_utility_64_unsigned_read Read a ULONG64 from memory */
+/* Media driver */
+/* */
+/* CALLED BY */
+/* */
+/* Application Driver */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 10-31-2022 Xiuwen Cai Initial Version 6.2.0 */
+/* */
+/**************************************************************************/
+UINT _fx_partition_offset_calculate_extended(FX_MEDIA *media_ptr, void *partition_sector, UINT partition,
+ ULONG *partition_start, ULONG *partition_size)
+{
+
+ULONG64 total_sectors;
+UCHAR *partition_sector_ptr;
+UCHAR partition_type;
+UINT i;
+ULONG base_sector;
+ULONG base_sector_extended;
+
+
+ /* Setup working pointer. */
+ partition_sector_ptr = partition_sector;
+
+ /* Check for a real boot sector instead of a partition table. */
+ if ((partition_sector_ptr[0] == 0xe9) || ((partition_sector_ptr[0] == 0xeb) && (partition_sector_ptr[2] == 0x90)))
+ {
+
+ /* Yes, a real boot sector could be present. */
+
+ /* See if there are good values for sectors per FAT. */
+ if (partition_sector_ptr[0x16] || partition_sector_ptr[0x17] || partition_sector_ptr[0x24] || partition_sector_ptr[0x25] || partition_sector_ptr[0x26] || partition_sector_ptr[0x27])
+ {
+
+ /* There are values for sectors per FAT. */
+
+ /* Get the total sectors, FAT12/16. */
+ total_sectors = _fx_utility_16_unsigned_read(&partition_sector_ptr[FX_SECTORS]);
+
+ if (total_sectors == 0)
+ {
+
+ /* Get the total sectors, FAT32. */
+ total_sectors = _fx_utility_32_unsigned_read(&partition_sector_ptr[FX_HUGE_SECTORS]);
+ }
+
+ /* Determine if there is a total sector count. */
+ if (total_sectors)
+ {
+
+ if (partition_start != FX_NULL)
+ {
+ /* Return an offset of 0, size of boot record, and a successful status. */
+ *partition_start = 0;
+ }
+
+ /* Determine if the total sectors is required. */
+ if (partition_size != FX_NULL)
+ {
+
+ /* Return the total sectors. */
+ *partition_size = (ULONG)(total_sectors & 0xFFFFFFFF);
+ }
+
+ /* Return success! */
+ return(FX_SUCCESS);
+ }
+ }
+#ifdef FX_ENABLE_EXFAT
+ /* See if there are good values for sectors per exFAT. */
+ else if (partition_sector_ptr[0x0b] == 0 && partition_sector_ptr[0x0c] == 0)
+ {
+ /* There are values for sectors per exFAT. */
+
+ /* Calculate the total sectors. */
+ total_sectors = _fx_utility_64_unsigned_read(&partition_sector_ptr[FX_EF_VOLUME_LENGTH]);
+
+ /* Determine if there is a total sector count. */
+ if (total_sectors)
+ {
+
+ if (partition_start != FX_NULL)
+ {
+ /* Return an offset of 0, size of boot record, and a successful status. */
+ *partition_start = 0;
+ }
+
+ /* Determine if the total sectors is required. */
+ if (partition_size != FX_NULL)
+ {
+
+ if (total_sectors > 0xFFFFFFFF)
+ {
+
+ /* Overflow. Just return not found. */
+ return(FX_NOT_FOUND);
+ }
+
+ /* Return the total sectors. */
+ *partition_size = (ULONG)(total_sectors & 0xFFFFFFFF);
+ }
+
+ /* Return success! */
+ return(FX_SUCCESS);
+ }
+ }
+#endif /* FX_ENABLE_EXFAT */
+ }
+
+ /* Check signature to make sure the buffer is valid. */
+ if ((partition_sector_ptr[510] != FX_SIG_BYTE_1) || (partition_sector_ptr[511] != FX_SIG_BYTE_2))
+ {
+
+ /* Invalid, return an error. */
+ return(FX_NOT_FOUND);
+ }
+
+ /* Not bootable, look for specific partition. */
+
+ /* Check if primary partitions are addressed. */
+ if (partition < 4)
+ {
+
+ /* Get partition type. */
+ partition_type = partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + partition * FX_PARTITION_ENTRY_SIZE + FX_PARTITION_TYPE_OFFSET];
+
+ /* Check if there is a vaild partition. */
+ if (partition_type != FX_PARTITION_TYPE_FREE)
+ {
+
+ /* Return the partition starting sector, if non-NULL. */
+ if (partition_start != FX_NULL)
+ {
+ *partition_start = _fx_utility_32_unsigned_read(&partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + partition * FX_PARTITION_ENTRY_SIZE + FX_PARTITION_LBA_OFFSET]);
+ }
+
+ /* Return the partition size, if non-NULL. */
+ if (partition_size != FX_NULL)
+ {
+ *partition_size = _fx_utility_32_unsigned_read(&partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + partition * FX_PARTITION_ENTRY_SIZE + FX_PARTITION_SECTORS_OFFSET]);
+ }
+
+ /* Return success! */
+ return(FX_SUCCESS);
+ }
+ else
+ {
+
+ /* Not partition here. */
+ return(FX_NOT_FOUND);
+ }
+ }
+
+ /* Check for invalid parameter. */
+ if (partition > FX_MAX_PARTITION_COUNT)
+ {
+
+ /* Return error. */
+ return(FX_NOT_FOUND);
+ }
+
+ base_sector = 0;
+
+ /* Loop to find the extended partition table. */
+ for(i = FX_PARTITION_TABLE_OFFSET; i <= FX_PARTITION_TABLE_OFFSET + 3 * FX_PARTITION_ENTRY_SIZE; i += FX_PARTITION_ENTRY_SIZE)
+ {
+
+ /* Get partition type. */
+ partition_type = partition_sector_ptr[i + FX_PARTITION_TYPE_OFFSET];
+ if (partition_type == FX_PARTITION_TYPE_EXTENDED || partition_type == FX_PARTITION_TYPE_EXTENDED_LBA)
+ {
+ base_sector = _fx_utility_32_unsigned_read(&partition_sector_ptr[i + FX_PARTITION_LBA_OFFSET]);
+ break;
+ }
+ }
+
+ if (base_sector == 0)
+ {
+
+ /* No extended partition. */
+ return(FX_NOT_FOUND);
+ }
+
+ base_sector_extended = base_sector;
+
+ for (i = 4; i <= partition; i++)
+ {
+
+ /* Read the partition sector from the device. Build the read sector
+ command. */
+ media_ptr -> fx_media_driver_request = FX_DRIVER_READ;
+ media_ptr -> fx_media_driver_status = FX_IO_ERROR;
+ media_ptr -> fx_media_driver_buffer = partition_sector_ptr;
+ media_ptr -> fx_media_driver_logical_sector = base_sector;
+ media_ptr -> fx_media_driver_sectors = 1;
+ media_ptr -> fx_media_driver_sector_type = FX_UNKNOWN_SECTOR;
+ media_ptr -> fx_media_hidden_sectors = 0;
+
+ /* Invoke the driver to read the sector. */
+ (media_ptr -> fx_media_driver_entry) (media_ptr);
+
+ /* Determine if the sector was read correctly. */
+ if (media_ptr -> fx_media_driver_status != FX_SUCCESS)
+ {
+
+ /* Return error. */
+ return(FX_IO_ERROR);
+ }
+
+ /* Check signature to make sure the sector is valid. */
+ if ((partition_sector_ptr[510] != FX_SIG_BYTE_1) || (partition_sector_ptr[511] != FX_SIG_BYTE_2))
+ {
+
+ /* Invalid, return an error. */
+ return(FX_NOT_FOUND);
+ }
+
+ /* Determine if this is the desired partition. */
+ if (i == partition)
+ {
+
+ /* Get partition type. */
+ partition_type = partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + FX_PARTITION_TYPE_OFFSET];
+ if (partition_type != FX_PARTITION_TYPE_FREE)
+ {
+
+ /* Return the partition starting sector, if non-NULL. */
+ if (partition_start != FX_NULL)
+ {
+ *partition_start = _fx_utility_32_unsigned_read(&partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + FX_PARTITION_LBA_OFFSET]) + base_sector;
+ }
+
+ /* Return the partition size, if non-NULL. */
+ if (partition_size != FX_NULL)
+ {
+ *partition_size = _fx_utility_32_unsigned_read(&partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + FX_PARTITION_SECTORS_OFFSET]);
+ }
+
+ /* Return success! */
+ return(FX_SUCCESS);
+ }
+ else
+ {
+ /* Not partition here. */
+ return(FX_NOT_FOUND);
+ }
+ }
+ else
+ {
+
+ /* Get partition type. */
+ partition_type = partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + FX_PARTITION_ENTRY_SIZE + FX_PARTITION_TYPE_OFFSET];
+ if (partition_type == FX_PARTITION_TYPE_EXTENDED || partition_type == FX_PARTITION_TYPE_EXTENDED_LBA)
+ {
+
+ /* Update sector number for next partition table. */
+ base_sector = _fx_utility_32_unsigned_read(&partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + FX_PARTITION_ENTRY_SIZE + FX_PARTITION_LBA_OFFSET]) + base_sector_extended;
+ }
+ else
+ {
+ /* No valid partition, get out of the loop. */
+ break;
+ }
+ }
+
+ }
+
+ /* Return error. */
+ return(FX_NOT_FOUND);
+}
\ No newline at end of file
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_FAT_entry_read.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_FAT_entry_read.c
index 5a10df7a..496c3a03 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_FAT_entry_read.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_FAT_entry_read.c
@@ -38,7 +38,7 @@
/* FUNCTION RELEASE */
/* */
/* _fx_utility_FAT_entry_read PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -80,6 +80,9 @@
/* added conditional to */
/* disable fat entry refresh, */
/* resulting in version 6.1 */
+/* 10-31-2022 Tiejun Zhou Modified comment(s), and */
+/* fixed compiler warning, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _fx_utility_FAT_entry_read(FX_MEDIA *media_ptr, ULONG cluster, ULONG *entry_ptr)
@@ -91,7 +94,9 @@ UCHAR *FAT_ptr;
UINT entry, index;
UINT status;
FX_FAT_CACHE_ENTRY *cache_entry_ptr;
+#ifndef FX_DISABLE_FAT_ENTRY_REFRESH
FX_FAT_CACHE_ENTRY temp_cache_entry;
+#endif /* FX_DISABLE_FAT_ENTRY_REFRESH */
#ifdef FX_ENABLE_FAULT_TOLERANT
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_logical_sector_read.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_logical_sector_read.c
index 0b831684..54140c57 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_logical_sector_read.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_logical_sector_read.c
@@ -38,7 +38,7 @@
/* FUNCTION RELEASE */
/* */
/* _fx_utility_logical_sector_read PORTABLE C */
-/* 6.1.6 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
@@ -96,6 +96,10 @@
/* updated check for logical */
/* sector value, */
/* resulting in version 6.1.6 */
+/* 10-31-2022 Tiejun Zhou Modified comment(s), */
+/* fixed memory buffer when */
+/* cache is disabled, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _fx_utility_logical_sector_read(FX_MEDIA *media_ptr, ULONG64 logical_sector,
@@ -342,6 +346,24 @@ UINT status;
#else
if ((logical_sector == media_ptr -> fx_media_memory_buffer_sector) && (sectors == 1) && (buffer_ptr == media_ptr -> fx_media_memory_buffer))
{
+#ifdef FX_ENABLE_FAULT_TOLERANT
+ if (media_ptr -> fx_media_fault_tolerant_enabled &&
+ (media_ptr -> fx_media_fault_tolerant_state & FX_FAULT_TOLERANT_STATE_STARTED) &&
+ (sector_type == FX_DIRECTORY_SECTOR))
+ {
+
+ /* Read sector from log file. */
+ status = _fx_fault_tolerant_read_directory_sector(media_ptr, logical_sector, buffer_ptr, 1);
+
+ /* Check for successful completion. */
+ if (status)
+ {
+
+ /* Return the error status. */
+ return(status);
+ }
+ }
+#endif /* FX_ENABLE_FAULT_TOLERANT */
return(FX_SUCCESS);
}
#endif
@@ -456,6 +478,24 @@ UINT status;
if ((media_ptr -> fx_media_driver_status == FX_SUCCESS) && (sectors == 1) && (buffer_ptr == media_ptr -> fx_media_memory_buffer))
{
media_ptr -> fx_media_memory_buffer_sector = logical_sector;
+#ifdef FX_ENABLE_FAULT_TOLERANT
+ if (media_ptr -> fx_media_fault_tolerant_enabled &&
+ (media_ptr -> fx_media_fault_tolerant_state & FX_FAULT_TOLERANT_STATE_STARTED) &&
+ (sector_type == FX_DIRECTORY_SECTOR))
+ {
+
+ /* Read sector from log file. */
+ status = _fx_fault_tolerant_read_directory_sector(media_ptr, logical_sector, buffer_ptr, 1);
+
+ /* Check for successful completion. */
+ if (status)
+ {
+
+ /* Return the error status. */
+ return(status);
+ }
+ }
+#endif /* FX_ENABLE_FAULT_TOLERANT */
return(FX_SUCCESS);
}
#endif /* FX_DISABLE_CACHE */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/ports/generic/inc/fx_port.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/ports/generic/inc/fx_port.h
index 3c8c9e08..6832c408 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/ports/generic/inc/fx_port.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/ports/generic/inc/fx_port.h
@@ -213,7 +213,7 @@ typedef unsigned long long ULONG64;
#ifdef FX_SYSTEM_INIT
CHAR _fx_version_id[] =
- "Copyright (c) Microsoft Corporation. All rights reserved. * FileX Generic Version 6.1.11 *";
+ "Copyright (c) Microsoft Corporation. All rights reserved. * FileX Generic Version 6.2.0 *";
#else
extern CHAR _fx_version_id[];
#endif
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/CMakeLists.txt b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/CMakeLists.txt
index ae1796d7..21cf3dda 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/CMakeLists.txt
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/CMakeLists.txt
@@ -25,6 +25,7 @@ target_sources(${PROJECT_NAME}
${CMAKE_CURRENT_LIST_DIR}/src/nx_arp_static_entry_create.c
${CMAKE_CURRENT_LIST_DIR}/src/nx_arp_static_entry_delete.c
${CMAKE_CURRENT_LIST_DIR}/src/nx_arp_static_entry_delete_internal.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/nx_http_proxy_client.c
${CMAKE_CURRENT_LIST_DIR}/src/nx_icmp_cleanup.c
${CMAKE_CURRENT_LIST_DIR}/src/nx_icmp_enable.c
${CMAKE_CURRENT_LIST_DIR}/src/nx_icmp_info_get.c
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_api.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_api.h
index 7bdb81f8..9b20cf8c 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_api.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_api.h
@@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* nx_api.h PORTABLE C */
-/* 6.1.11 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -88,6 +88,15 @@
/* added internal ip address */
/* change notification, */
/* resulting in version 6.1.11 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* updated product constants, */
+/* fixed compiler errors when */
+/* TX_SAFETY_CRITICAL is */
+/* enabled, */
+/* resulting in version 6.1.12 */
+/* 10-31-2022 Wenhui Xie Modified comment(s), and */
+/* supported HTTP Proxy, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -112,12 +121,15 @@ extern "C" {
/* Bypass ThreadX API error checking for internal NetX calls. */
+#include "tx_port.h"
#ifdef NX_SOURCE_CODE
+#ifndef TX_SAFETY_CRITICAL
#ifndef TX_DISABLE_ERROR_CHECKING
#define TX_DISABLE_ERROR_CHECKING
#endif
#endif
+#endif
@@ -500,8 +512,8 @@ VOID _nx_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, ULONG
/* Define basic constants for the NetX TCP/IP Stack. */
#define AZURE_RTOS_NETXDUO
#define NETXDUO_MAJOR_VERSION 6
-#define NETXDUO_MINOR_VERSION 1
-#define NETXDUO_PATCH_VERSION 11
+#define NETXDUO_MINOR_VERSION 2
+#define NETXDUO_PATCH_VERSION 0
/* Define the following symbols for backward compatibility */
#define EL_PRODUCT_NETXDUO
@@ -1201,6 +1213,22 @@ typedef struct NX_IPV6_DEFAULT_ROUTER_ENTRY_STRUCT
#define NX_MAX_LISTEN_REQUESTS 10
#endif
+/* Define the max length of username and password for HTTP Proxy authentication. */
+
+/* Define the max length of username. */
+#ifndef NX_HTTP_PROXY_MAX_USERNAME
+#define NX_HTTP_PROXY_MAX_USERNAME 20
+#endif
+
+/* Define the max length of password. */
+#ifndef NX_HTTP_PROXY_MAX_PASSWORD
+#define NX_HTTP_PROXY_MAX_PASSWORD 20
+#endif
+
+/* NX_HTTP_PROXY_MAX_AUTHENTICATION is the max length of base64 of "name:password",
+ 1 bytes for an extra conversion if needed, 2 bytes for pad if needed, 1 byte for null terminator and four byte alignment. */
+#define NX_HTTP_PROXY_MAX_AUTHENTICATION (((((NX_HTTP_PROXY_MAX_USERNAME + NX_HTTP_PROXY_MAX_PASSWORD + 1 ) * 4 / 3) + 1 + 2 + 1) / 4 + 1) * 4)
+
/* Define the IP status checking/return bits. */
@@ -1934,9 +1962,22 @@ typedef struct NX_TCP_SOCKET_STRUCT
/* Define whether or not TCP socket is in fast recovery procedure. */
UCHAR nx_tcp_socket_fast_recovery;
+#ifdef NX_ENABLE_HTTP_PROXY
+
+ /* Define the state of HTTP Proxy connection. */
+ UCHAR nx_tcp_socket_http_proxy_state;
+
+ /* Define the packet to store HTTP response header. */
+ NX_PACKET *nx_tcp_socket_http_proxy_header_packet;
+
+ /* Define the IP and port for original server. */
+ NXD_ADDRESS nx_tcp_socket_original_server_ip;
+ UINT nx_tcp_socket_original_server_port;
+#else
/* Reserved to four bytes alignment. */
/*lint -esym(768,NX_TCP_SOCKET_STRUCT::nx_tcp_socket_reserved) suppress member not referenced. It is reserved for future use. */
UCHAR nx_tcp_socket_reserved;
+#endif /* NX_ENABLE_HTTP_PROXY */
/* Define the entry that this TCP socket belongs to. */
struct NX_IP_STRUCT
@@ -2806,6 +2847,21 @@ typedef struct NX_IP_STRUCT
NX_TCP_LISTEN
*nx_ip_tcp_active_listen_requests;
+#ifdef NX_ENABLE_HTTP_PROXY
+ /* Define the IP address of HTTP proxy server. */
+ NXD_ADDRESS nx_ip_http_proxy_ip_address;
+
+ /* Define the port of HTTP proxy server. */
+ USHORT nx_ip_http_proxy_port;
+
+ /* Define the flag indicating the HTTP proxy is enabled. */
+ USHORT nx_ip_http_proxy_enable;
+
+ /* Define the buffer for HTTP proxy authentication. */
+ UCHAR nx_ip_http_proxy_authentication[NX_HTTP_PROXY_MAX_AUTHENTICATION];
+ UINT nx_ip_http_proxy_authentication_length;
+#endif /* NX_ENABLE_HTTP_PROXY */
+
/* Define a flag indicating the IP fast timer has been created */
UINT nx_ip_fast_periodic_timer_created;
@@ -3257,6 +3313,7 @@ typedef struct NX_IP_DRIVER_STRUCT
/* APIs for others. */
#define nx_system_initialize _nx_system_initialize
+#define nx_http_proxy_client_enable _nx_http_proxy_client_enable
#else
@@ -3444,6 +3501,7 @@ typedef struct NX_IP_DRIVER_STRUCT
/* APIs for others. */
#define nx_system_initialize _nx_system_initialize
+#define nx_http_proxy_client_enable _nxe_http_proxy_client_enable
#endif
@@ -3781,6 +3839,8 @@ UINT nxd_udp_packet_info_extract(NX_PACKET *packet_ptr, NXD_ADDRESS *ip_address,
/* APIs for others. */
VOID nx_system_initialize(VOID);
+UINT nx_http_proxy_client_enable(NX_IP *ip_ptr, NXD_ADDRESS *proxy_server_ip, UINT proxy_server_port,
+ UCHAR *username, UINT username_length, UCHAR *password, UINT password_length);
/* Define several function prototypes for exclusive use by NetX I/O drivers. These routines
are used by NetX drivers to report received packets to NetX. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_http_proxy_client.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_http_proxy_client.h
new file mode 100644
index 00000000..78566d46
--- /dev/null
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_http_proxy_client.h
@@ -0,0 +1,89 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) Microsoft Corporation. All rights reserved. */
+/* */
+/* This software is licensed under the Microsoft Software License */
+/* Terms for Microsoft Azure RTOS. Full text of the license can be */
+/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
+/* and in the root directory of this software. */
+/* */
+/**************************************************************************/
+
+
+/**************************************************************************/
+/**************************************************************************/
+/** */
+/** NetX Component */
+/** */
+/** HTTP Proxy Protocol */
+/** */
+/**************************************************************************/
+/**************************************************************************/
+
+/**************************************************************************/
+/* */
+/* APPLICATION INTERFACE DEFINITION RELEASE */
+/* */
+/* nx_http_proxy_client.h PORTABLE C */
+/* 6.2.0 */
+/* AUTHOR */
+/* */
+/* Wenhui Xie, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This file defines the Hypertext Transfer Protocol(HTTP) Proxy */
+/* component, including all data types and external references. */
+/* It is assumed that nx_api.h and nx_port.h have already been */
+/* included. */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 10-31-2022 Wenhui Xie Initial Version 6.2.0 */
+/* */
+/**************************************************************************/
+
+#ifndef NX_HTTP_PROXY_CLIENT_H
+#define NX_HTTP_PROXY_CLIENT_H
+
+/* Determine if a C++ compiler is being used. If so, ensure that standard
+ C is used to process the API information. */
+
+
+#ifdef __cplusplus
+
+/* Yes, C++ compiler is present. Use standard C. */
+extern "C" {
+
+#endif
+
+#include "nx_api.h"
+
+/* Define the states for HTTP Proxy connection. */
+#define NX_HTTP_PROXY_STATE_INIT 0
+#define NX_HTTP_PROXY_STATE_WAITING 1
+#define NX_HTTP_PROXY_STATE_CONNECTING 2
+#define NX_HTTP_PROXY_STATE_CONNECTED 3
+
+/* Define HTTP Proxy function prototypes. */
+UINT _nx_http_proxy_client_enable(NX_IP *ip_ptr, NXD_ADDRESS *proxy_server_ip, UINT proxy_server_port,
+ UCHAR *username, UINT username_length, UCHAR *password, UINT password_length);
+VOID _nx_http_proxy_client_initialize(NX_TCP_SOCKET *socket_ptr, NXD_ADDRESS **server_ip, UINT *server_port);
+UINT _nx_http_proxy_client_connect(NX_TCP_SOCKET *socket_ptr);
+UINT _nx_http_proxy_client_connect_response_process(NX_TCP_SOCKET *socket_ptr);
+VOID _nx_http_proxy_client_cleanup(NX_TCP_SOCKET *socket_ptr);
+
+/* Define error checking shells for API services. These are only referenced by the
+ application. */
+UINT _nxe_http_proxy_client_enable(NX_IP *ip_ptr, NXD_ADDRESS *proxy_server_ip, UINT proxy_server_port,
+ UCHAR *username, UINT username_length, UCHAR *password, UINT password_length);
+
+/* Determine if a C++ compiler is being used. If so, complete the standard
+ C conditional started above. */
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* NX_HTTP_PROXY_CLIENT_H */
\ No newline at end of file
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_icmpv6.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_icmpv6.h
index 6e0441fc..15b2e196 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_icmpv6.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_icmpv6.h
@@ -212,7 +212,7 @@ typedef struct NX_ICMPV6_OPTION_STRUCT
/* Size of the option. */
UCHAR nx_icmpv6_option_length;
- /* Option data. */
+ /* Option data. This field is used to retrieve starting address of option. The size is decided by option length. */
USHORT nx_icmpv6_option_data;
} NX_ICMPV6_OPTION;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_na.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_na.c
index 523eedc2..acfd9452 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_na.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_na.c
@@ -238,7 +238,7 @@ UINT i;
/*lint -e{927} suppress cast of pointer to pointer, since it is necessary */
/*lint -e{644} suppress variable might not be initialized, since "nd_entry" was initialized in _nx_nd_cache_find_entry. */
lla = (USHORT *)nd_entry -> nx_nd_cache_mac_addr;
- if ((new_lla[0] == lla[0]) && (new_lla[1] == lla[1]) && (new_lla[2] == lla[2]))
+ if ((new_lla[0] == lla[0]) && (new_lla[1] == lla[1]) && (new_lla[2] == lla[2])) /* lgtm[cpp/overflow-buffer] */
{
/* No change in LLA. */
@@ -391,8 +391,8 @@ UINT i;
/*lint -e{927} suppress cast of pointer to pointer, since it is necessary */
lla = (USHORT *)nd_entry -> nx_nd_cache_mac_addr;
lla[0] = new_lla[0];
- lla[1] = new_lla[1];
- lla[2] = new_lla[2];
+ lla[1] = new_lla[1]; /* lgtm[cpp/overflow-buffer] */
+ lla[2] = new_lla[2]; /* lgtm[cpp/overflow-buffer] */
}
if (nd_ptr -> nx_icmpv6_nd_flag & 0x40000000) /* S bit is set, force cache entry to REACHABLE */
{
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ns.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ns.c
index c35cd22d..9cdc06f1 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ns.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ns.c
@@ -285,7 +285,7 @@ ULONG dest_address[4];
mac_lsw = ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[2]) << 24) | ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[3]) << 16) |
((ULONG)(nd_entry -> nx_nd_cache_mac_addr[4]) << 8) | nd_entry -> nx_nd_cache_mac_addr[5];
new_msw = ((ULONG)(new_mac[0]) << 8) | (new_mac[1]);
- new_lsw = ((ULONG)(new_mac[2]) << 24) | ((ULONG)(new_mac[3]) << 16) | ((ULONG)(new_mac[4]) << 8) | new_mac[5];
+ new_lsw = ((ULONG)(new_mac[2]) << 24) | ((ULONG)(new_mac[3]) << 16) | ((ULONG)(new_mac[4]) << 8) | new_mac[5]; /* lgtm[cpp/overflow-buffer] */
if ((mac_msw != new_msw) || (mac_lsw != new_lsw)) /* If the new MAC is different from what we have in the table. */
{
@@ -410,12 +410,12 @@ ULONG dest_address[4];
mac_addr = &option_ptr -> nx_icmpv6_option_data;
mac_addr[0] = (USHORT)(interface_addr -> nxd_ipv6_address_attached -> nx_interface_physical_address_msw);
- mac_addr[1] = (USHORT)((interface_addr -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0xFFFF0000) >> 16);
- mac_addr[2] = (USHORT)(interface_addr -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0x0000FFFF);
+ mac_addr[1] = (USHORT)((interface_addr -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0xFFFF0000) >> 16); /* lgtm[cpp/overflow-buffer] */
+ mac_addr[2] = (USHORT)(interface_addr -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0x0000FFFF); /* lgtm[cpp/overflow-buffer] */
NX_CHANGE_USHORT_ENDIAN(mac_addr[0]);
- NX_CHANGE_USHORT_ENDIAN(mac_addr[1]);
- NX_CHANGE_USHORT_ENDIAN(mac_addr[2]);
+ NX_CHANGE_USHORT_ENDIAN(mac_addr[1]); /* lgtm[cpp/overflow-buffer] */
+ NX_CHANGE_USHORT_ENDIAN(mac_addr[2]); /* lgtm[cpp/overflow-buffer] */
#ifdef NX_DISABLE_ICMPV6_TX_CHECKSUM
compute_checksum = 0;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ra.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ra.c
index fd3dc7ce..423576a1 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ra.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ra.c
@@ -455,7 +455,7 @@ UINT interface_index;
mac_lsw = ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[2]) << 24) | ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[3]) << 16) |
((ULONG)(nd_entry -> nx_nd_cache_mac_addr[4]) << 8) | nd_entry -> nx_nd_cache_mac_addr[5];
new_msw = ((ULONG)(new_mac[0]) << 8) | (new_mac[1]);
- new_lsw = ((ULONG)(new_mac[2]) << 24) | ((ULONG)(new_mac[3]) << 16) | ((ULONG)(new_mac[4]) << 8) | new_mac[5];
+ new_lsw = ((ULONG)(new_mac[2]) << 24) | ((ULONG)(new_mac[3]) << 16) | ((ULONG)(new_mac[4]) << 8) | new_mac[5]; /* lgtm[cpp/overflow-buffer] */
if ((mac_msw != new_msw) || (mac_lsw != new_lsw))
{
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_redirect.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_redirect.c
index 920d22a5..8c42db68 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_redirect.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_redirect.c
@@ -303,7 +303,7 @@ NX_IPV6_DESTINATION_ENTRY *dest_entry_ptr;
new_msw = ((ULONG)(new_mac[0]) << 8) | (new_mac[1]);
mac_lsw = ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[2]) << 24) | ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[3]) << 16) |
((ULONG)(nd_entry -> nx_nd_cache_mac_addr[4]) << 8) | nd_entry -> nx_nd_cache_mac_addr[5];
- new_lsw = ((ULONG)(new_mac[2]) << 24) | ((ULONG)(new_mac[3]) << 16) | ((ULONG)(new_mac[4]) << 8) | new_mac[5];
+ new_lsw = ((ULONG)(new_mac[2]) << 24) | ((ULONG)(new_mac[3]) << 16) | ((ULONG)(new_mac[4]) << 8) | new_mac[5]; /* lgtm[cpp/overflow-buffer] */
if ((mac_msw != new_msw) || (mac_lsw != new_lsw)) /* If the new MAC is different. */
{
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_ns.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_ns.c
index 903d3329..0c2a32e1 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_ns.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_ns.c
@@ -226,13 +226,13 @@ NX_IP_DRIVER driver_request;
/* Fill in the source MAC address */
mac_addr = &nd_options -> nx_icmpv6_option_data;
mac_addr[0] = (USHORT)(outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_msw);
- mac_addr[1] = (USHORT)((outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0xFFFF0000) >> 16);
- mac_addr[2] = (USHORT)(outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0x0000FFFF);
+ mac_addr[1] = (USHORT)((outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0xFFFF0000) >> 16); /* lgtm[cpp/overflow-buffer] */
+ mac_addr[2] = (USHORT)(outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0x0000FFFF); /* lgtm[cpp/overflow-buffer] */
/* Byte swapping. */
NX_CHANGE_USHORT_ENDIAN(mac_addr[0]);
- NX_CHANGE_USHORT_ENDIAN(mac_addr[1]);
- NX_CHANGE_USHORT_ENDIAN(mac_addr[2]);
+ NX_CHANGE_USHORT_ENDIAN(mac_addr[1]); /* lgtm[cpp/overflow-buffer] */
+ NX_CHANGE_USHORT_ENDIAN(mac_addr[2]); /* lgtm[cpp/overflow-buffer] */
}
#ifdef NX_DISABLE_ICMPV6_TX_CHECKSUM
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_rs.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_rs.c
index 7ff18deb..eb3f0ae9 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_rs.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_rs.c
@@ -164,13 +164,13 @@ NX_ICMPV6_OPTION *rs_options;
/* Fill in the source mac address. */
mac_addr = &rs_options -> nx_icmpv6_option_data;
mac_addr[0] = (USHORT)(ip_ptr -> nx_ip_interface[if_index].nx_interface_physical_address_msw);
- mac_addr[1] = (USHORT)((ip_ptr -> nx_ip_interface[if_index].nx_interface_physical_address_lsw & 0xFFFF0000) >> 16);
- mac_addr[2] = (USHORT)(ip_ptr -> nx_ip_interface[if_index].nx_interface_physical_address_lsw & 0x0000FFFF);
+ mac_addr[1] = (USHORT)((ip_ptr -> nx_ip_interface[if_index].nx_interface_physical_address_lsw & 0xFFFF0000) >> 16); /* lgtm[cpp/overflow-buffer] */
+ mac_addr[2] = (USHORT)(ip_ptr -> nx_ip_interface[if_index].nx_interface_physical_address_lsw & 0x0000FFFF); /* lgtm[cpp/overflow-buffer] */
/* Byte swapping. */
NX_CHANGE_USHORT_ENDIAN(mac_addr[0]);
- NX_CHANGE_USHORT_ENDIAN(mac_addr[1]);
- NX_CHANGE_USHORT_ENDIAN(mac_addr[2]);
+ NX_CHANGE_USHORT_ENDIAN(mac_addr[1]); /* lgtm[cpp/overflow-buffer] */
+ NX_CHANGE_USHORT_ENDIAN(mac_addr[2]); /* lgtm[cpp/overflow-buffer] */
#ifdef NX_DISABLE_ICMPV6_TX_CHECKSUM
compute_checksum = 0;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_md5.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_md5.c
index 68567c88..deeea5d4 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_md5.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_md5.c
@@ -242,7 +242,7 @@ ULONG needed_fill_bytes;
/* Copy the appropriate portion of the input buffer into the internal
buffer of the context. */
- memcpy((void *) &(context -> nx_md5_buffer[current_bytes]), (void *) input_ptr, needed_fill_bytes); /* Use case of memcpy is verified. */
+ memcpy((void *) &(context -> nx_md5_buffer[current_bytes]), (void *) input_ptr, needed_fill_bytes); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */
/* Process the 64-byte (512 bit) buffer. */
_nx_md5_process_buffer(context, context -> nx_md5_buffer);
@@ -273,7 +273,7 @@ ULONG needed_fill_bytes;
/* Save the remaining bytes in the internal buffer after any remaining bytes
that it is processed later. */
- memcpy((void *) &(context -> nx_md5_buffer[current_bytes]), (void *) input_ptr, input_length); /* Use case of memcpy is verified. */
+ memcpy((void *) &(context -> nx_md5_buffer[current_bytes]), (void *) input_ptr, input_length); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */
}
/* Return success. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_adjust.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_adjust.c
index fd34c8aa..103d5cab 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_adjust.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_adjust.c
@@ -154,7 +154,7 @@ NX_PACKET *work_ptr;
}
/* Firstly, append the overflowing data to the new packet.. */
- memcpy(work_ptr -> nx_packet_prepend_ptr, data_start, append_size); /* Use case of memcpy is verified. */
+ memcpy(work_ptr -> nx_packet_prepend_ptr, data_start, append_size); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */
work_ptr -> nx_packet_append_ptr = (UCHAR *)((ALIGN_TYPE)work_ptr -> nx_packet_prepend_ptr + append_size);
/* Secondly, calculate the shift data size. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_append.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_append.c
index 20b66dd1..b7318941 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_append.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_append.c
@@ -265,7 +265,7 @@ NX_PACKET *work_ptr; /* Working packet pointer */
#endif /* NX_DISABLE_PACKET_CHAIN */
/* Copy the data into the current packet buffer. */
- memcpy(work_ptr -> nx_packet_append_ptr, source_ptr, copy_size); /* Use case of memcpy is verified. */
+ memcpy(work_ptr -> nx_packet_append_ptr, source_ptr, copy_size); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */
/* Adjust the remaining data size. */
data_size = data_size - copy_size;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_extract_offset.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_extract_offset.c
index 813448af..9a892d57 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_extract_offset.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_extract_offset.c
@@ -187,7 +187,7 @@ NX_PACKET *working_packet_ptr;
}
/* Copy data from this packet. */
- memcpy(destination_ptr, source_ptr, bytes_to_copy); /* Use case of memcpy is verified. */
+ memcpy(destination_ptr, source_ptr, bytes_to_copy); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */
/* Update the pointers. */
destination_ptr += bytes_to_copy;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_retrieve.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_retrieve.c
index 97a8afde..75a419a0 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_retrieve.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_retrieve.c
@@ -103,7 +103,7 @@ ULONG bytes_to_copy;
/* Copy data to destination. */
/* Note: The buffer size must be not less than packet_ptr -> nx_packet_length. */
- memcpy(destination_ptr, packet_ptr -> nx_packet_prepend_ptr, bytes_to_copy); /* Use case of memcpy is verified. The buffer is provided by user. */
+ memcpy(destination_ptr, packet_ptr -> nx_packet_prepend_ptr, bytes_to_copy); /* Use case of memcpy is verified. The buffer is provided by user. lgtm[cpp/banned-api-usage-required-any] */
remaining_bytes -= bytes_to_copy;
destination_ptr += bytes_to_copy;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_block_cleanup.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_block_cleanup.c
index 3270d683..544f8e79 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_block_cleanup.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_block_cleanup.c
@@ -28,13 +28,16 @@
#include "nx_api.h"
#include "nx_tcp.h"
#include "nx_ipv6.h"
+#ifdef NX_ENABLE_HTTP_PROXY
+#include "nx_http_proxy_client.h"
+#endif /* NX_ENABLE_HTTP_PROXY */
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nx_tcp_socket_block_cleanup PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -53,7 +56,7 @@
/* */
/* CALLS */
/* */
-/* None */
+/* _nx_http_proxy_client_cleanup Clean up HTTP Proxy */
/* */
/* CALLED BY */
/* */
@@ -70,6 +73,9 @@
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Wenhui Xie Modified comment(s), and */
+/* supported HTTP Proxy, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID _nx_tcp_socket_block_cleanup(NX_TCP_SOCKET *socket_ptr)
@@ -109,6 +115,15 @@ VOID _nx_tcp_socket_block_cleanup(NX_TCP_SOCKET *socket_ptr)
/* Client socket, return to a CLOSED state. */
socket_ptr -> nx_tcp_socket_state = NX_TCP_CLOSED;
+
+#ifdef NX_ENABLE_HTTP_PROXY
+ if (socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_http_proxy_enable)
+ {
+
+ /* Clean up the HTTP Proxy. */
+ _nx_http_proxy_client_cleanup(socket_ptr);
+ }
+#endif /* NX_ENABLE_HTTP_PROXY */
}
else
{
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_connection_reset.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_connection_reset.c
index 526493df..cf7500c3 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_connection_reset.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_connection_reset.c
@@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_tcp_socket_connection_reset PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -81,6 +81,10 @@
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* corrected the logic of */
+/* flushing receive queue. */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
VOID _nx_tcp_socket_connection_reset(NX_TCP_SOCKET *socket_ptr)
@@ -103,15 +107,6 @@ UINT saved_state;
_nx_tcp_socket_transmit_queue_flush(socket_ptr);
}
- /* Check for queued receive packets and if found they need
- to be released. */
- if (socket_ptr -> nx_tcp_socket_receive_queue_count)
- {
-
- /* Release all received packets. */
- _nx_tcp_socket_receive_queue_flush(socket_ptr);
- }
-
/* Clear all receive thread suspensions on this socket. */
while (socket_ptr -> nx_tcp_socket_receive_suspension_list)
{
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_packet_process.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_packet_process.c
index bac9f4b6..00b7945b 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_packet_process.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_packet_process.c
@@ -28,6 +28,9 @@
#include "nx_api.h"
#include "nx_tcp.h"
#include "nx_packet.h"
+#ifdef NX_ENABLE_HTTP_PROXY
+#include "nx_http_proxy_client.h"
+#endif /* NX_ENABLE_HTTP_PROXY */
/**************************************************************************/
@@ -35,7 +38,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_tcp_socket_packet_process PORTABLE C */
-/* 6.1.10 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -71,6 +74,9 @@
/* _nx_tcp_socket_state_transmit_check Check for transmit ability */
/* (nx_tcp_urgent_data_callback) Application urgent callback */
/* function */
+/* _nx_http_proxy_client_connect_response_process */
+/* Process HTTP Proxy CONNECT */
+/* response */
/* */
/* CALLED BY */
/* */
@@ -90,6 +96,9 @@
/* fixed unsigned integers */
/* comparison, */
/* resulting in version 6.1.10 */
+/* 10-31-2022 Wenhui Xie Modified comment(s), and */
+/* supported HTTP Proxy, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID _nx_tcp_socket_packet_process(NX_TCP_SOCKET *socket_ptr, NX_PACKET *packet_ptr)
@@ -458,6 +467,19 @@ ULONG tcpip_offload;
break;
}
+#ifdef NX_ENABLE_HTTP_PROXY
+
+ /* Check if HTTP Proxy is started and waiting for the response form the HTTP Proxy server. */
+ if ((socket_ptr -> nx_tcp_socket_state == NX_TCP_ESTABLISHED) &&
+ (socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_http_proxy_enable) &&
+ (socket_ptr -> nx_tcp_socket_http_proxy_state == NX_HTTP_PROXY_STATE_CONNECTING))
+ {
+
+ /* Receive and process the response. */
+ _nx_http_proxy_client_connect_response_process(socket_ptr);
+ }
+#endif /* NX_ENABLE_HTTP_PROXY */
+
/* Check for an URG (urgent) bit set. */
/*lint -e{644} suppress variable might not be initialized, since "tcp_header_copy" was initialized. */
if (tcp_header_copy.nx_tcp_header_word_3 & NX_TCP_URG_BIT)
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_data_check.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_data_check.c
index 031d7868..e23023d0 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_data_check.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_data_check.c
@@ -27,6 +27,9 @@
#include "nx_packet.h"
#include "nx_ip.h"
#include "nx_tcp.h"
+#ifdef NX_ENABLE_HTTP_PROXY
+#include "nx_http_proxy_client.h"
+#endif /* NX_ENABLE_HTTP_PROXY */
/**************************************************************************/
@@ -34,7 +37,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_tcp_socket_state_data_trim PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -69,6 +72,9 @@
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Wenhui Xie Modified comment(s), and */
+/* supported HTTP Proxy, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID _nx_tcp_socket_state_data_trim(NX_PACKET *packet_ptr, ULONG amount)
@@ -276,7 +282,7 @@ ULONG work_length;
/* FUNCTION RELEASE */
/* */
/* _nx_tcp_socket_state_data_check PORTABLE C */
-/* 6.1.10 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -324,6 +330,9 @@ ULONG work_length;
/* fixed unsigned integers */
/* comparison, */
/* resulting in version 6.1.10 */
+/* 10-31-2022 Wenhui Xie Modified comment(s), and */
+/* supported HTTP Proxy, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_tcp_socket_state_data_check(NX_TCP_SOCKET *socket_ptr, NX_PACKET *packet_ptr)
@@ -1091,7 +1100,11 @@ NX_IP *ip_ptr;
packet is already queued. */
/* Any packets for receiving? */
- while (acked_packets && socket_ptr -> nx_tcp_socket_receive_suspension_list)
+ while (acked_packets && socket_ptr -> nx_tcp_socket_receive_suspension_list
+#ifdef NX_ENABLE_HTTP_PROXY
+ && (socket_ptr -> nx_tcp_socket_http_proxy_state != NX_HTTP_PROXY_STATE_CONNECTING)
+#endif /* NX_ENABLE_HTTP_PROXY */
+ )
{
/* Setup a pointer to the first queued packet. */
@@ -1171,13 +1184,22 @@ NX_IP *ip_ptr;
#endif /* NX_ENABLE_TCPIP_OFFLOAD */
)
{
- /* Determine if there is a socket receive notification function specified. */
- if (socket_ptr -> nx_tcp_receive_callback)
+
+#ifdef NX_ENABLE_HTTP_PROXY
+
+ /* If HTTP Proxy is connecting, the data is the response from HTTP Proxy server, don't need to notify application. */
+ if (socket_ptr -> nx_tcp_socket_http_proxy_state != NX_HTTP_PROXY_STATE_CONNECTING)
+#endif /* NX_ENABLE_HTTP_PROXY */
{
- /* Yes, notification is requested. Call the application's receive notification
- function for this socket. */
- (socket_ptr -> nx_tcp_receive_callback)(socket_ptr);
+ /* Determine if there is a socket receive notification function specified. */
+ if (socket_ptr -> nx_tcp_receive_callback)
+ {
+
+ /* Yes, notification is requested. Call the application's receive notification
+ function for this socket. */
+ (socket_ptr -> nx_tcp_receive_callback)(socket_ptr);
+ }
}
#ifdef NX_TCP_ACK_EVERY_N_PACKETS
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_established.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_established.c
index 4cae6a85..082dee63 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_established.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_established.c
@@ -28,6 +28,9 @@
#include "nx_api.h"
#include "nx_ip.h"
#include "nx_tcp.h"
+#ifdef NX_ENABLE_HTTP_PROXY
+#include "nx_http_proxy_client.h"
+#endif /* NX_ENABLE_HTTP_PROXY */
/**************************************************************************/
@@ -35,7 +38,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_tcp_socket_state_established PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -74,6 +77,9 @@
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Wenhui Xie Modified comment(s), and */
+/* supported HTTP Proxy, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID _nx_tcp_socket_state_established(NX_TCP_SOCKET *socket_ptr)
@@ -127,14 +133,28 @@ NX_IP *ip_ptr;
/* Send ACK message. */
_nx_tcp_packet_send_ack(socket_ptr, socket_ptr -> nx_tcp_socket_tx_sequence);
- /* If given, call the application's disconnect callback function
- for disconnect. */
- if (socket_ptr -> nx_tcp_disconnect_callback)
+#ifdef NX_ENABLE_HTTP_PROXY
+ if ((ip_ptr -> nx_ip_http_proxy_enable) &&
+ (socket_ptr -> nx_tcp_socket_http_proxy_state == NX_HTTP_PROXY_STATE_CONNECTING))
{
- /* Call the application's disconnect handling function. It is
- responsible for calling the socket disconnect function. */
- (socket_ptr -> nx_tcp_disconnect_callback)(socket_ptr);
+ /* If received FIN before HTTP Proxy connection established, disconnect the TCP connection
+ and don't notify the application. */
+ _nx_tcp_socket_disconnect(socket_ptr, NX_NO_WAIT);
+ }
+ else
+#endif /* NX_ENABLE_HTTP_PROXY */
+ {
+
+ /* If given, call the application's disconnect callback function
+ for disconnect. */
+ if (socket_ptr -> nx_tcp_disconnect_callback)
+ {
+
+ /* Call the application's disconnect handling function. It is
+ responsible for calling the socket disconnect function. */
+ (socket_ptr -> nx_tcp_disconnect_callback)(socket_ptr);
+ }
}
}
}
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_syn_sent.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_syn_sent.c
index 2ff220f0..97426200 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_syn_sent.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_syn_sent.c
@@ -27,6 +27,9 @@
#include "nx_api.h"
#include "nx_tcp.h"
+#ifdef NX_ENABLE_HTTP_PROXY
+#include "nx_http_proxy_client.h"
+#endif /* NX_ENABLE_HTTP_PROXY */
/**************************************************************************/
@@ -34,7 +37,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_tcp_socket_state_syn_sent PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -62,6 +65,7 @@
/* _nx_tcp_packet_send_syn Send SYN packet */
/* _nx_tcp_packet_send_rst Send RST packet */
/* _nx_tcp_socket_thread_resume Resume suspended thread */
+/* _nx_http_proxy_client_connect Connect with HTTP Proxy */
/* */
/* CALLED BY */
/* */
@@ -74,6 +78,9 @@
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Wenhui Xie Modified comment(s), and */
+/* supported HTTP Proxy, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID _nx_tcp_socket_state_syn_sent(NX_TCP_SOCKET *socket_ptr, NX_TCP_HEADER *tcp_header_ptr, NX_PACKET *packet_ptr)
@@ -185,17 +192,6 @@ VOID _nx_tcp_socket_state_syn_sent(NX_TCP_SOCKET *socket_ptr, NX_TCP_HEADER *tc
/* Clear the socket timeout. */
socket_ptr -> nx_tcp_socket_timeout = 0;
-#ifndef NX_DISABLE_EXTENDED_NOTIFY_SUPPORT
-
- /* Is a connection completion callback registered with the TCP socket? */
- if (socket_ptr -> nx_tcp_establish_notify)
- {
-
- /* Call the application's establish callback function. */
- (socket_ptr -> nx_tcp_establish_notify)(socket_ptr);
- }
-#endif
-
#ifdef NX_ENABLE_TCP_KEEPALIVE
/* Is the keepalive feature enabled on this socket? */
if (socket_ptr -> nx_tcp_socket_keepalive_enabled)
@@ -206,12 +202,37 @@ VOID _nx_tcp_socket_state_syn_sent(NX_TCP_SOCKET *socket_ptr, NX_TCP_HEADER *tc
}
#endif
- /* Determine if we need to wake a thread suspended on the connection. */
- if (socket_ptr -> nx_tcp_socket_connect_suspended_thread)
+#ifdef NX_ENABLE_HTTP_PROXY
+
+ /* Check if the HTTP Proxy is started and waiting for TCP socket connection. */
+ if ((socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_http_proxy_enable) &&
+ (socket_ptr -> nx_tcp_socket_http_proxy_state == NX_HTTP_PROXY_STATE_WAITING))
{
- /* Resume the suspended thread. */
- _nx_tcp_socket_thread_resume(&(socket_ptr -> nx_tcp_socket_connect_suspended_thread), NX_SUCCESS);
+ /* TCP connection established, start the HTTP Proxy connection. */
+ _nx_http_proxy_client_connect(socket_ptr);
+ }
+ else
+#endif /* NX_ENABLE_HTTP_PROXY */
+ {
+#ifndef NX_DISABLE_EXTENDED_NOTIFY_SUPPORT
+
+ /* Is a connection completion callback registered with the TCP socket? */
+ if (socket_ptr -> nx_tcp_establish_notify)
+ {
+
+ /* Call the application's establish callback function. */
+ (socket_ptr -> nx_tcp_establish_notify)(socket_ptr);
+ }
+#endif
+
+ /* Determine if we need to wake a thread suspended on the connection. */
+ if (socket_ptr -> nx_tcp_socket_connect_suspended_thread)
+ {
+
+ /* Resume the suspended thread. */
+ _nx_tcp_socket_thread_resume(&(socket_ptr -> nx_tcp_socket_connect_suspended_thread), NX_SUCCESS);
+ }
}
}
else if ((tcp_header_ptr -> nx_tcp_header_word_3 & NX_TCP_SYN_BIT) &&
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_wait.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_wait.c
index e52bc6e3..63f534ed 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_wait.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_wait.c
@@ -27,6 +27,9 @@
#include "nx_api.h"
#include "nx_tcp.h"
+#ifdef NX_ENABLE_HTTP_PROXY
+#include "nx_http_proxy_client.h"
+#endif /* NX_ENABLE_HTTP_PROXY */
/**************************************************************************/
@@ -34,7 +37,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_tcp_socket_state_wait PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -69,6 +72,9 @@
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Wenhui Xie Modified comment(s), and */
+/* supported HTTP Proxy, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_tcp_socket_state_wait(NX_TCP_SOCKET *socket_ptr, UINT desired_state, ULONG wait_option)
@@ -93,8 +99,16 @@ UINT _nx_tcp_socket_state_wait(NX_TCP_SOCKET *socket_ptr, UINT desired_state, U
if (socket_ptr -> nx_tcp_socket_state == desired_state)
{
- /* The desired state is present, return success! */
- return(NX_SUCCESS);
+#ifdef NX_ENABLE_HTTP_PROXY
+ if ((desired_state != NX_TCP_ESTABLISHED) ||
+ (!socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_http_proxy_enable) ||
+ (!socket_ptr -> nx_tcp_socket_client_type) ||
+ (socket_ptr -> nx_tcp_socket_http_proxy_state == NX_HTTP_PROXY_STATE_CONNECTED))
+#endif /* NX_ENABLE_HTTP_PROXY */
+ {
+ /* The desired state is present, return success! */
+ return(NX_SUCCESS);
+ }
}
/* Check to see if there is more time to wait. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_utility.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_utility.c
index 036430ae..00e76dab 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_utility.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_utility.c
@@ -318,7 +318,7 @@ UINT size;
/* FUNCTION RELEASE */
/* */
/* _nx_utility_base64_encode PORTABLE C */
-/* 6.1.6 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -353,6 +353,9 @@ UINT size;
/* DATE NAME DESCRIPTION */
/* */
/* 04-02-2021 Yuxin Zhou Initial Version 6.1.6 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), */
+/* improved the internal logic,*/
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_utility_base64_encode(UCHAR *name, UINT name_size, UCHAR *base64name, UINT base64name_size, UINT *bytes_copied)
@@ -360,6 +363,7 @@ UINT _nx_utility_base64_encode(UCHAR *name, UINT name_size, UCHAR *base64name, U
UINT pad;
UINT i, j;
UINT step;
+UINT input_name_size = name_size;
/* Check for invalid input pointers. */
@@ -422,7 +426,16 @@ UINT step;
{
/* Use last 2 bits of name character and first 4 bits of next name character for index. */
- base64name[j++] = (UCHAR)_nx_utility_base64_array[((((UCHAR)name[i]) & 0x3) << 4) | (((UCHAR)name[i + 1]) >> 4)];
+ if ((i + 1) < input_name_size)
+ {
+ base64name[j++] = (UCHAR)_nx_utility_base64_array[((((UCHAR)name[i]) & 0x3) << 4) | (((UCHAR)name[i + 1]) >> 4)];
+ }
+ else
+ {
+
+ /* If no more name character, pad with zero. */
+ base64name[j++] = (UCHAR)_nx_utility_base64_array[(((UCHAR)name[i]) & 0x3) << 4];
+ }
i++;
step++;
}
@@ -430,7 +443,16 @@ UINT step;
{
/* Use last 4 bits of name character and first 2 bits of next name character for index. */
- base64name[j++] = (UCHAR)_nx_utility_base64_array[((((UCHAR)name[i]) & 0xF) << 2) | (((UCHAR)name[i + 1]) >> 6)];
+ if ((i + 1) < input_name_size)
+ {
+ base64name[j++] = (UCHAR)_nx_utility_base64_array[((((UCHAR)name[i]) & 0xF) << 2) | (((UCHAR)name[i + 1]) >> 6)];
+ }
+ else
+ {
+
+ /* If no more name character, pad with zero. */
+ base64name[j++] = (UCHAR)_nx_utility_base64_array[(((UCHAR)name[i]) & 0xF) << 2];
+ }
i++;
step++;
}
@@ -444,12 +466,6 @@ UINT step;
}
}
- /* Determine if the index needs to be advanced. */
- if (step != 3)
- {
- i++;
- }
-
/* Now add the PAD characters. */
while (pad--)
{
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nxd_tcp_client_socket_connect.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nxd_tcp_client_socket_connect.c
index a2df3662..2cf3bc3a 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nxd_tcp_client_socket_connect.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nxd_tcp_client_socket_connect.c
@@ -31,6 +31,9 @@
#include "nx_ipv6.h"
#include "nx_ipv4.h"
#include "nx_ip.h"
+#ifdef NX_ENABLE_HTTP_PROXY
+#include "nx_http_proxy_client.h"
+#endif /* NX_ENABLE_HTTP_PROXY */
#ifdef NX_ENABLE_TCPIP_OFFLOAD
@@ -188,7 +191,7 @@ NX_IP *ip_ptr;
/* FUNCTION RELEASE */
/* */
/* _nxd_tcp_client_socket_connect PORTABLE C */
-/* 6.1.8 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -218,6 +221,7 @@ NX_IP *ip_ptr;
/* interface. */
/* tx_mutex_get Obtain protection */
/* tx_mutex_put Release protection */
+/* _nx_http_proxy_client_initialize Initialize the HTTP Proxy */
/* */
/* CALLED BY */
/* */
@@ -233,6 +237,9 @@ NX_IP *ip_ptr;
/* 08-02-2021 Yuxin Zhou Modified comment(s), and */
/* supported TCP/IP offload, */
/* resulting in version 6.1.8 */
+/* 10-31-2022 Wenhui Xie Modified comment(s), and */
+/* supported HTTP Proxy, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nxd_tcp_client_socket_connect(NX_TCP_SOCKET *socket_ptr,
@@ -256,6 +263,15 @@ ULONG ip_address_log = 0;
/* Setup IP pointer. */
ip_ptr = socket_ptr -> nx_tcp_socket_ip_ptr;
+#ifdef NX_ENABLE_HTTP_PROXY
+ if (ip_ptr -> nx_ip_http_proxy_enable)
+ {
+
+ /* Initialize the HTTP Proxy info and replace the peer IP and port with HTTP proxy server's IP and port. */
+ _nx_http_proxy_client_initialize(socket_ptr, &server_ip, &server_port);
+ }
+#endif /* NX_ENABLE_HTTP_PROXY */
+
/* Make sure the server IP address is accesible. */
#ifndef NX_DISABLE_IPV4
if (server_ip -> nxd_ip_version == NX_IP_VERSION_V4)
@@ -477,6 +493,15 @@ ULONG ip_address_log = 0;
_nx_tcp_packet_send_syn(socket_ptr, (socket_ptr -> nx_tcp_socket_tx_sequence - 1));
}
+#ifdef NX_ENABLE_HTTP_PROXY
+ if (ip_ptr -> nx_ip_http_proxy_enable)
+ {
+
+ /* Set HTTP Proxy state as waiting for TCP connection. */
+ socket_ptr -> nx_tcp_socket_http_proxy_state = NX_HTTP_PROXY_STATE_WAITING;
+ }
+#endif /* NX_ENABLE_HTTP_PROXY */
+
/* Optionally suspend the thread. If timeout occurs, return a connection timeout status. If
immediate response is selected, return a connection in progress status. Only on a real
connection should success be returned. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/nx_user.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/nx_user.h
index 28351191..c2420740 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/nx_user.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/nx_user.h
@@ -869,5 +869,71 @@
#define NX_ENABLE_TCPIP_OFFLOAD
#endif
+/* Defined, the secure settings */
+#define USE_NX_SECURE_TLS_DISABLE_TLS_1_1 0
+#if USE_NX_SECURE_TLS_DISABLE_TLS_1_1
+#define NX_SECURE_TLS_DISABLE_TLS_1_1
+#endif
+
+/* Defined, the DNS settings */
+#define USE_NX_DNS_CLIENT_USER_CREATE_PACKET_POOL 0
+#if USE_NX_DNS_CLIENT_USER_CREATE_PACKET_POOL
+#define NX_DNS_CLIENT_USER_CREATE_PACKET_POOL
+#endif
+
+#define USE_NX_DNS_CLIENT_CLEAR_QUEUE 0
+#if USE_NX_DNS_CLIENT_CLEAR_QUEUE
+#define NX_DNS_CLIENT_CLEAR_QUEUE
+#endif
+
+/* Defined, the MQTT settings */
+#define USE_NXD_MQTT_PING_TIMEOUT_DELAY 0
+#if USE_NXD_MQTT_PING_TIMEOUT_DELAY
+#define NXD_MQTT_PING_TIMEOUT_DELAY 500
+#endif
+
+#define USE_NXD_MQTT_SOCKET_TIMEOUT 0
+#if USE_NXD_MQTT_SOCKET_TIMEOUT
+#define NXD_MQTT_SOCKET_TIMEOUT 0
+#endif
+
+/* Defined, the SNTP settings */
+#define USE_NX_SNTP_CLIENT_MIN_SERVER_STRATUM 0
+#if USE_NX_SNTP_CLIENT_MIN_SERVER_STRATUM
+#define NX_SNTP_CLIENT_MIN_SERVER_STRATUM 3
+#endif
+
+#define USE_NX_SNTP_CLIENT_MAX_ROOT_DISPERSION 0
+#if USE_NX_SNTP_CLIENT_MAX_ROOT_DISPERSION
+#define NX_SNTP_CLIENT_MAX_ROOT_DISPERSION 0
+#endif
+
+#define USE_NX_SNTP_CURRENT_YEAR 0
+#if USE_NX_SNTP_CURRENT_YEAR
+#define NX_SNTP_CURRENT_YEAR 2022
+#endif
+
+/* Defined, the Azure IoT Security Module settings */
+#define USE_NX_AZURE_DISABLE_IOT_SECURITY_MODULE 0
+#if USE_NX_AZURE_DISABLE_IOT_SECURITY_MODULE
+#define NX_AZURE_DISABLE_IOT_SECURITY_MODULE
+#endif
+
+/* Defined, the Azure Device Update settings */
+#define USE_NX_AZURE_IOT_ADU_AGENT_PROXY_UPDATE_COUNT 0
+#if USE_NX_AZURE_IOT_ADU_AGENT_PROXY_UPDATE_COUNT
+#define NX_AZURE_IOT_ADU_AGENT_PROXY_UPDATE_COUNT 0
+#endif
+
+/* Defined, the device information for Azure IoT */
+#define USE_NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_DEVICE_VENDOR 0
+#if USE_NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_DEVICE_VENDOR
+#define NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_DEVICE_VENDOR 4
+#endif
+
+#define USE_NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_DEVICE_TYPE 0
+#if USE_NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_DEVICE_TYPE
+#define NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_DEVICE_TYPE "RX65N-RSK"
+#endif
#endif
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/ports/rxv2/gnu/inc/nx_port.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/ports/rxv2/gnu/inc/nx_port.h
index c00c758c..97b364ac 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/ports/rxv2/gnu/inc/nx_port.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/ports/rxv2/gnu/inc/nx_port.h
@@ -204,7 +204,7 @@
#ifdef NX_SYSTEM_INIT
CHAR _nx_version_id[] =
- "Copyright (c) Microsoft Corporation. All rights reserved. * NetX Duo RXv2/GNU Version 6.1.11 *";
+ "Copyright (c) Microsoft Corporation. All rights reserved. * NetX Duo RXv2/GNU Version 6.2.0 *";
#else
extern CHAR _nx_version_id[];
#endif
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/CHANGELOG.md b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/CHANGELOG.md
index e96df1a0..5ae42406 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/CHANGELOG.md
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/CHANGELOG.md
@@ -1,5 +1,10 @@
# Release History
+## 1.3.2 (2022-07-07)
+
+### Other Changes
+ - Removed unreachable code in `az_http_policy_retry.c`.
+
## 1.3.1 (2022-04-05)
### Bugs Fixed
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/README.md b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/README.md
index 3d21d9d4..21f6af93 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/README.md
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/README.md
@@ -202,6 +202,11 @@ The following CMake options are available for adding/removing project features.
This option can be set to any of the next values: - No_value: default value is used and no_platform library is used. - "POSIX": Provides implementation for Linux and Mac systems. - "WIN32": Provides platform implementation for Windows based system - "CUSTOM": Tells cmake to use an specific implementation provided by user. When setting this option, user must provide an implementation library and set option `AZ_CUSTOM_PLATFORM_IMPL_NAME` with the name of the library (i.e. -DAZ_PLATFORM_IMPL=CUSTOM -DAZ_CUSTOM_PLATFORM_IMPL_NAME=user_platform_lib). cmake will look for this library to link az_core |
No_value |
+
+| ADDRESS_SANITIZER |
+This option enables asan (address sanitizer). This works on Windows and Linux and will catch memory errors at runtime. This option may also work on other platforms supporting address sanitizer. Do not use this option in production as asan is not a hardening tool and can leak layout information and defeat ASLR. |
+OFF |
+
- ``Samples``: Storage Samples are built by default using the default PAL and HTTP adapter (see [running samples](#running-samples)). This means that running samples without building an HTTP transport adapter would throw errors like:
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/cmake-modules/AddAzureSDKforC.cmake b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/cmake-modules/AddAzureSDKforC.cmake
index e573dc97..1dcf3e99 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/cmake-modules/AddAzureSDKforC.cmake
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/cmake-modules/AddAzureSDKforC.cmake
@@ -17,7 +17,7 @@
include(FetchContent)
FetchContent_Declare(azuresdkforc
GIT_REPOSITORY https://github.com/Azure/azure-sdk-for-c.git
- GIT_TAG 1.3.1)
+ GIT_TAG 1.3.2)
FetchContent_GetProperties(azuresdkforc)
if(NOT azuresdkforc_POPULATED)
FetchContent_Populate(azuresdkforc)
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/az_version.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/az_version.h
index d31a5bfe..a8391237 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/az_version.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/az_version.h
@@ -17,7 +17,7 @@
/// The version in string format used for telemetry following the `semver.org` standard
/// (https://semver.org).
-#define AZ_SDK_VERSION_STRING "1.3.1"
+#define AZ_SDK_VERSION_STRING "1.3.2"
/// Major numeric identifier.
#define AZ_SDK_VERSION_MAJOR 1
@@ -26,7 +26,7 @@
#define AZ_SDK_VERSION_MINOR 3
/// Patch numeric identifier.
-#define AZ_SDK_VERSION_PATCH 1
+#define AZ_SDK_VERSION_PATCH 2
/// Optional pre-release identifier. SDK is in a pre-release state when present.
#define AZ_SDK_VERSION_PRERELEASE
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_config_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_config_internal.h
index 151cec55..6433ac14 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_config_internal.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_config_internal.h
@@ -1,6 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
+/**
+ * @file
+ *
+ * @brief Defines internal constants.
+ *
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
+ */
+
#ifndef _az_CONFIG_INTERNAL_H
#define _az_CONFIG_INTERNAL_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_credentials_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_credentials_internal.h
index 081ebc19..b6032e8b 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_credentials_internal.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_credentials_internal.h
@@ -1,6 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
+/**
+ * @file
+ *
+ * @brief Defines internals used by credentials.
+ *
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
+ */
+
#ifndef _az_CREDENTIALS_INTERNAL_H
#define _az_CREDENTIALS_INTERNAL_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_http_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_http_internal.h
index 4bdbed00..d5df4693 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_http_internal.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_http_internal.h
@@ -1,6 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
+/**
+ * @file
+ *
+ * @brief Defines internals used by http.
+ *
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
+ */
+
#ifndef _az_HTTP_INTERNAL_H
#define _az_HTTP_INTERNAL_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_log_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_log_internal.h
index c38f0bcd..562b0450 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_log_internal.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_log_internal.h
@@ -1,6 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
+/**
+ * @file
+ *
+ * @brief Defines internals used by log.
+ *
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
+ */
+
#ifndef _az_LOG_INTERNAL_H
#define _az_LOG_INTERNAL_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_precondition_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_precondition_internal.h
index 33459a2d..e542d733 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_precondition_internal.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_precondition_internal.h
@@ -27,6 +27,11 @@
* code (or adding option -DPRECONDITIONS=OFF with cmake), all of the Azure SDK
* precondition checking will be excluding making the binary code smaller and faster. We
* recommend doing this before you ship your code.
+ *
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
*/
#ifndef _az_PRECONDITION_INTERNAL_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_retry_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_retry_internal.h
index 41105343..d0cec399 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_retry_internal.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_retry_internal.h
@@ -1,6 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
+/**
+ * @file
+ *
+ * @brief Defines internals used by retry.
+ *
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
+ */
+
#ifndef _az_RETRY_INTERNAL_H
#define _az_RETRY_INTERNAL_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_span_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_span_internal.h
index 792b323e..d3f23c60 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_span_internal.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_span_internal.h
@@ -1,6 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
+/**
+ * @file
+ *
+ * @brief Defines internals used by span.
+ *
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
+ */
+
#ifndef _az_SPAN_INTERNAL_H
#define _az_SPAN_INTERNAL_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_hex_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_hex_private.h
index 2c323dd0..e0e04ae5 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_hex_private.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_hex_private.h
@@ -1,6 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
+/**
+ * @file
+ *
+ * @brief Defines private implementation used by hex.
+ *
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
+ */
+
#ifndef _az_HEX_PRIVATE_H
#define _az_HEX_PRIVATE_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_header_validation_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_header_validation_private.h
index e8fd5a21..3744f9b2 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_header_validation_private.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_header_validation_private.h
@@ -7,6 +7,10 @@
* @brief This header defines a bit array that is used to validate whenever or not an ASCII char is
* valid within an http header name.
*
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
*/
#ifndef _az_HTTP_HEADER_VALIDATION_PRIVATE_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_logging_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_logging_private.h
index eb53d498..eb7babd1 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_logging_private.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_logging_private.h
@@ -1,6 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
+/**
+ * @file
+ *
+ * @brief Defines private implementation used by http logging.
+ *
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
+ */
+
#ifndef _az_HTTP_POLICY_LOGGING_PRIVATE_H
#define _az_HTTP_POLICY_LOGGING_PRIVATE_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_retry.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_retry.c
index f897b820..64fd9e67 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_retry.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_retry.c
@@ -220,6 +220,4 @@ AZ_NODISCARD az_result az_http_pipeline_policy_retry(
}
}
}
-
- return result;
}
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_private.h
index 63dd531c..482eb959 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_private.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_private.h
@@ -1,6 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
+/**
+ * @file
+ *
+ * @brief Defines private implementation used by http.
+ *
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
+ */
+
#ifndef _az_HTTP_PRIVATE_H
#define _az_HTTP_PRIVATE_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_json_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_json_private.h
index ef2ef72e..db19e163 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_json_private.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_json_private.h
@@ -1,6 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
+/**
+ * @file
+ *
+ * @brief Defines private implementation used by json.
+ *
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
+ */
+
#ifndef _az_JSON_PRIVATE_H
#define _az_JSON_PRIVATE_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_span_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_span_private.h
index 40229579..0e46251a 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_span_private.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_span_private.h
@@ -1,6 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
+/**
+ * @file
+ *
+ * @brief Defines private implementation used by span.
+ *
+ * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.)
+ * prefixed with an underscore ('_') directly in your application code. These symbols
+ * are part of Azure SDK's internal implementation; we do not document these symbols
+ * and they are subject to change in future versions of the SDK which would break your code.
+ */
+
#ifndef _az_SPAN_PRIVATE_H
#define _az_SPAN_PRIVATE_H
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/configs/RTOS_BASE.dist b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/configs/RTOS_BASE.dist
index d873124e..aeba666c 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/configs/RTOS_BASE.dist
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/configs/RTOS_BASE.dist
@@ -4,7 +4,7 @@ CONF_DEFINE_BASE(${g_core_config_path} base_dist.cmake)
# DIST: overwrite configuration for specific distribution
set(SECURITY_MODULE_VERSION_MAJOR 3)
set(SECURITY_MODULE_VERSION_MINOR 5)
-set(SECURITY_MODULE_VERSION_PATCH 2)
+set(SECURITY_MODULE_VERSION_PATCH 4)
set(ASC_COMPONENT_CONFIGURATION OFF)
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/L4_BASE/asc_config.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/L4_BASE/asc_config.h
index 3ca55fbc..87384977 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/L4_BASE/asc_config.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/L4_BASE/asc_config.h
@@ -21,13 +21,13 @@ extern "C" {
/********************
* Core configuration
*********************/
-/* Based on 2021.09.28-3.5.1 core tag */
+/* Based on 2022.07.19-3.5.3 core tag */
/* ID and version */
#define ASC_SECURITY_MODULE_ID "defender-iot-micro-agent"
#define SECURITY_MODULE_VERSION_MAJOR 3
#define SECURITY_MODULE_VERSION_MINOR 5
-#define SECURITY_MODULE_VERSION_PATCH 2
+#define SECURITY_MODULE_VERSION_PATCH 4
#ifndef SECURITY_MODULE_VERSION_MAJOR
#define SECURITY_MODULE_VERSION_MAJOR 0
#endif
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE/asc_config.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE/asc_config.h
index f3e8a248..de0fdc6f 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE/asc_config.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE/asc_config.h
@@ -21,13 +21,13 @@ extern "C" {
/********************
* Core configuration
*********************/
-/* Based on 2021.09.28-3.5.1 core tag */
+/* Based on 2022.07.19-3.5.3 core tag */
/* ID and version */
#define ASC_SECURITY_MODULE_ID "defender-iot-micro-agent"
#define SECURITY_MODULE_VERSION_MAJOR 3
#define SECURITY_MODULE_VERSION_MINOR 5
-#define SECURITY_MODULE_VERSION_PATCH 2
+#define SECURITY_MODULE_VERSION_PATCH 4
#ifndef SECURITY_MODULE_VERSION_MAJOR
#define SECURITY_MODULE_VERSION_MAJOR 0
#endif
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE_UT/asc_config.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE_UT/asc_config.h
index 96e7a7e8..8fdaa8db 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE_UT/asc_config.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE_UT/asc_config.h
@@ -21,13 +21,13 @@ extern "C" {
/********************
* Core configuration
*********************/
-/* Based on 2021.09.28-3.5.1 core tag */
+/* Based on 2022.07.19-3.5.3 core tag */
/* ID and version */
#define ASC_SECURITY_MODULE_ID "defender-iot-micro-agent"
#define SECURITY_MODULE_VERSION_MAJOR 3
#define SECURITY_MODULE_VERSION_MINOR 5
-#define SECURITY_MODULE_VERSION_PATCH 2
+#define SECURITY_MODULE_VERSION_PATCH 4
#ifndef SECURITY_MODULE_VERSION_MAJOR
#define SECURITY_MODULE_VERSION_MAJOR 0
#endif
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/configs/asc_config.h.in b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/configs/asc_config.h.in
index 6f15cf84..e66d358f 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/configs/asc_config.h.in
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/configs/asc_config.h.in
@@ -1,7 +1,7 @@
/********************
* Core configuration
*********************/
-/* Based on 2021.09.28-3.5.1 core tag */
+/* Based on 2022.07.19-3.5.3 core tag */
/* ID and version */
#cmakedefine ASC_SECURITY_MODULE_ID "@ASC_SECURITY_MODULE_ID@"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_alloc.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_alloc.h
index 71015e4e..06ca4a0b 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_alloc.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_alloc.h
@@ -1,6 +1,5 @@
#ifndef FLATCC_ALLOC_H
#define FLATCC_ALLOC_H
-#include
#ifdef __cplusplus
extern "C" {
@@ -46,6 +45,7 @@ extern "C" {
#include
+#include
/* ASC Disable memory allocation usage */
#ifdef ASC_SERIALIZER_USE_CUSTOM_ALLOCATOR
#define FLATCC_ALLOC(n) NULL
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_emitter.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_emitter.h
index aff55ee5..69026e4e 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_emitter.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_emitter.h
@@ -1,6 +1,5 @@
#ifndef FLATCC_EMITTER_H
#define FLATCC_EMITTER_H
-#include
#ifdef __cplusplus
extern "C" {
@@ -20,6 +19,8 @@ extern "C" {
#include
#include
+#include
+
#include "flatcc/flatcc_types.h"
#include "flatcc/flatcc_iov.h"
#include "flatcc/flatcc_alloc.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_endian.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_endian.h
index 0592f313..c07b7bce 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_endian.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_endian.h
@@ -97,11 +97,11 @@ extern "C" {
/* flatcc/portable/pendian.h sets LITTLE/BIG flags if possible, and always defines le16toh. */
#ifndef flatbuffers_is_native_pe
-#if defined(__LITTLE_ENDIAN__) || FLATBUFFERS_LITTLEENDIAN
+#if (__LITTLE_ENDIAN__==1) || FLATBUFFERS_LITTLEENDIAN
#undef FLATBUFFERS_LITTLEENDIAN
#define FLATBUFFERS_LITTLEENDIAN 1
#define flatbuffers_is_native_pe() (FLATBUFFERS_PROTOCOL_IS_LE)
-#elif defined(__BIG_ENDIAN__) || (defined(FLATBUFFERS_LITTLEENDIAN) && !FLATBUFFERS_LITTLEENDIAN)
+#elif (__BIG_ENDIAN__==1) || (defined(FLATBUFFERS_LITTLEENDIAN) && !FLATBUFFERS_LITTLEENDIAN)
#undef FLATBUFFERS_LITTLEENDIAN
#define FLATBUFFERS_LITTLEENDIAN 0
#define flatbuffers_is_native_pe() (FLATBUFFERS_PROTOCOL_IS_BE)
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian.h
index 122ba8e2..3b174ba0 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian.h
@@ -131,7 +131,7 @@ extern "C" {
/* Assume it goes for all. */
#if !defined(le16toh)
-#if defined(__LITTLE_ENDIAN__)
+#if (__LITTLE_ENDIAN__==1)
#define le16toh(v) (v)
#define le32toh(v) (v)
@@ -149,7 +149,7 @@ extern "C" {
#define htobe32(v) bswap32(v)
#define htobe64(v) bswap64(v)
-#elif defined(__BIG_ENDIAN__)
+#elif (__BIG_ENDIAN__==1)
#define le16toh(v) bswap16(v)
#define le32toh(v) bswap32(v)
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian_detect.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian_detect.h
index f5ec75c5..5b8bf054 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian_detect.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian_detect.h
@@ -33,11 +33,11 @@ extern "C" {
#ifdef __BYTE_ORDER__
-#if defined(__LITTLE_ENDIAN__) && __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
+#if (__LITTLE_ENDIAN__ == 1) && __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
#error __LITTLE_ENDIAN__ inconsistent with __BYTE_ORDER__
#endif
-#if defined(__BIG_ENDIAN__) && __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__
+#if (__BIG_ENDIAN__ == 1) && __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__
#error __BIG_ENDIAN__ inconsistent with __BYTE_ORDER__
#endif
@@ -45,7 +45,7 @@ extern "C" {
#if \
- defined(__LITTLE_ENDIAN__) || \
+ (__LITTLE_ENDIAN__ == 1) || \
(defined(__BYTE_ORDER) && __BYTE_ORDER == __ORDER_LITTLE_ENDIAN) || \
defined(__ARMEL__) || defined(__THUMBEL__) || \
defined(__AARCH64EL__) || \
@@ -64,7 +64,7 @@ extern "C" {
#endif
#if \
- defined (__BIG_ENDIAN__) || \
+ (__BIG_ENDIAN__ == 1) || \
(defined(__BYTE_ORDER) && __BYTE_ORDER == __ORDER_BIG_ENDIAN) || \
defined(__ARMEB__) || defined(THUMBEB__) || defined (__AARCH64EB__) || \
defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) || \
@@ -107,7 +107,7 @@ extern "C" {
#endif
#endif /* __BYTE_ORDER__ */
-#if defined(__LITTLE_ENDIAN__) && defined(__BIG_ENDIAN__)
+#if (__LITTLE_ENDIAN__ == 1) && (__BIG_ENDIAN__ == 1)
#error conflicting definitions of __LITTLE_ENDIAN__ and __BIG_ENDIAN__
#endif
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/src/runtime/emitter.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/src/runtime/emitter.c
index c64db798..fe89d234 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/src/runtime/emitter.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/src/runtime/emitter.c
@@ -1,7 +1,7 @@
-#include
-
#include
+#include
+
#ifdef ASC_SERIALIZER_USE_CUSTOM_ALLOCATOR
#include "asc_security_core/serializer/page_allocator.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector.h
index c3c55125..4ac97c76 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector.h
@@ -11,11 +11,12 @@
#ifndef COLLECTOR_H
#define COLLECTOR_H
-#include
#include
#include
+#include
+
#include "asc_security_core/asc_result.h"
#include "asc_security_core/component_info.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector_collection.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector_collection.h
index 7d10c475..a2683b4f 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector_collection.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector_collection.h
@@ -11,10 +11,11 @@
#ifndef IOTSECURITY_COLLECTOR_COLLECTION_H
#define IOTSECURITY_COLLECTOR_COLLECTION_H
-#include
#include
+#include
+
#include "asc_security_core/asc_result.h"
#include "asc_security_core/collector.h"
#include "asc_security_core/utils/collection/list.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collectors_info.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collectors_info.h
index b753fda1..f1e400ce 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collectors_info.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collectors_info.h
@@ -11,10 +11,11 @@
#ifndef _COLLECTORS_INFO_H_
#define _COLLECTORS_INFO_H_
-#include
#include
+#include
+
#define COLLECTORS_INFO_SIZE COLLECTORS_COUNT
typedef struct {
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/component_info.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/component_info.h
index 164e73a9..1218e9c2 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/component_info.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/component_info.h
@@ -11,10 +11,11 @@
#ifndef __COMPONENT_INFO_H__
#define __COMPONENT_INFO_H__
-#include
#include
+#include
+
#include "asc_security_core/asc_result.h"
#include "asc_security_core/components_factory_enum.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory.h
index cfdbccf8..a9757951 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory.h
@@ -11,11 +11,11 @@
#ifndef __COMPONENTS_FACTORY_H__
#define __COMPONENTS_FACTORY_H__
-#include
#include
#include
+#include
#include "asc_security_core/logger.h"
#include "asc_security_core/utils/string_utils.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory_type.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory_type.h
index 79a7c50f..3328cdc2 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory_type.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory_type.h
@@ -11,10 +11,11 @@
#ifndef __COMPONENTS_FACTORY__TYPE_H__
#define __COMPONENTS_FACTORY__TYPE_H__
-#include
#include
+#include
+
#include "asc_security_core/asc_result.h"
#include "asc_security_core/component_info.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/core.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/core.h
index ec0f4cc8..96b8d97b 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/core.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/core.h
@@ -11,11 +11,12 @@
#ifndef CORE_H
#define CORE_H
-#include
#include
#include
+#include
+
#include "asc_security_core/asc_result.h"
#include "asc_security_core/collector_collection.h"
#include "asc_security_core/model/security_message.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/logger.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/logger.h
index 8adde4bc..ac0ea9c0 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/logger.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/logger.h
@@ -11,6 +11,12 @@
#ifndef LOGGER_H
#define LOGGER_H
+
+#include
+#include
+#include
+#include
+
#include
#define LOG_LEVEL_NOTSET 0
@@ -34,11 +40,6 @@
#define logger_set_timestamp(_s)
#define logger_get_system_log_level() (LOG_LEVEL_NOTSET)
#else
- #include
- #include
- #include
- #include
-
#include "asc_security_core/utils/macros.h"
#include "asc_security_core/component_id.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/network_activity.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/network_activity.h
index 82b2e871..99602774 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/network_activity.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/network_activity.h
@@ -11,10 +11,11 @@
#ifndef OBJECT_NETWORK_ACTIVITY_H
#define OBJECT_NETWORK_ACTIVITY_H
-#include
#include
+#include
+
#include "asc_security_core/model/objects/transport_protocol.h"
#include "asc_security_core/utils/collection/collection.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/system_information.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/system_information.h
index 1688a237..4ac54bf3 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/system_information.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/system_information.h
@@ -11,10 +11,11 @@
#ifndef OBJECT_SYSTEM_INFORMATION_H
#define OBJECT_SYSTEM_INFORMATION_H
-#include
#include
+#include
+
#include "asc_security_core/utils/collection/collection.h"
typedef struct system_information_t {
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/security_message.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/security_message.h
index 285fbb77..fb340441 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/security_message.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/security_message.h
@@ -11,11 +11,12 @@
#ifndef SECURITY_MESSAGE_H
#define SECURITY_MESSAGE_H
-#include
#include
#include
+#include
+
#include "asc_security_core/asc_result.h"
typedef struct {
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_def.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_def.h
index 17b0c4e9..0cbbfa29 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_def.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_def.h
@@ -11,10 +11,11 @@
#ifndef OBJECT_POOL_DEF_H
#define OBJECT_POOL_DEF_H
-#include
#include
+#include
+
#include "asc_security_core/utils/collection/stack.h"
typedef struct {
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_dynamic.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_dynamic.h
index 08969400..40fbf1ff 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_dynamic.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_dynamic.h
@@ -11,10 +11,11 @@
#ifndef OBJECT_POOL_DYNAMIC_H
#define OBJECT_POOL_DYNAMIC_H
-#include
#include
+#include
+
#include "asc_security_core/object_pool_def.h"
/* Pay your attention, that this implementation is not thread safe. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_static.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_static.h
index 911cfab9..9b1c8922 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_static.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_static.h
@@ -12,10 +12,11 @@
#ifndef OBJECT_POOL_STATIC_H
#define OBJECT_POOL_STATIC_H
-#include
#include
+#include
+
#include "asc_security_core/object_pool_def.h"
/* Pay your attention, that this implementation is not thread safe. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer.h
index 77578ee0..e5b7539b 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer.h
@@ -11,11 +11,12 @@
#ifndef SERIALIZER_H
#define SERIALIZER_H
-#include
#include
#include
+#include
+
#include "asc_security_core/asc_result.h"
#include "asc_security_core/model/objects/objects.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer/page_allocator.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer/page_allocator.h
index d94dafb1..2d1255be 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer/page_allocator.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer/page_allocator.h
@@ -11,10 +11,11 @@
#ifndef PAGE_ALLOCATOR_H
#define PAGE_ALLOCATOR_H
-#include
#include
+#include
+
#ifdef ASC_COLLECTOR_PROCESS_ENABLED
#include "asc_security_core/model/objects/process.h"
#define COLLECTOR_PROCESS_SIZE (ASC_COLLECTOR_PROCESS_IN_CACHE * sizeof(process_t))
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/bit_vector.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/bit_vector.h
index f2e021da..f9dc46c9 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/bit_vector.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/bit_vector.h
@@ -12,10 +12,10 @@
#ifndef __BIT_VECTOR_H__
#define __BIT_VECTOR_H__
-#include
-
#include
+#include
+
#define __BV_VEC_IND(index) (index>>3)
#define __BV_VEC_SHIFT(index) (index & 0x07)
#define __BV_CEIL_DIV8(x) ((x>>3)+(!!(x & 0x07)))
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashset.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashset.h
index 4ed2a56d..76cca0ad 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashset.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashset.h
@@ -11,10 +11,11 @@
#ifndef HASHSET_H
#define HASHSET_H
-#include
#include
+#include
+
#include "asc_security_core/utils/collection/collection.h"
/**
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashtable.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashtable.h
index f7374915..665f9c5f 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashtable.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashtable.h
@@ -11,12 +11,13 @@
#ifndef __HASHTABLE_H__
#define __HASHTABLE_H__
-#include
#include
#include
#include
+#include
+
#include "asc_security_core/utils/collection/collection.h"
/* Pay your attention, that this implementation is not thread safe. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/linked_list.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/linked_list.h
index 970b8eac..8e65b23c 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/linked_list.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/linked_list.h
@@ -11,13 +11,15 @@
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
-#include
-#include "asc_security_core/utils/collection/collection.h"
#include
#include
#include
+#include
+
+#include "asc_security_core/utils/collection/collection.h"
+
#define LINKED_LIST_DECLARATIONS(type) \
typedef void (*linked_list_##type##_deinit_function)(type *item);\
typedef void (*linked_list_##type##_action)(type *item, void *context);\
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/list.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/list.h
index 69b56177..fd850258 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/list.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/list.h
@@ -11,11 +11,12 @@
#ifndef __LIST_H__
#define __LIST_H__
-#include
#include
#include
+#include
+
#include "asc_security_core/utils/collection/collection.h"
/* Pay your attention, that this implementation is not thread safe. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/stack.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/stack.h
index dba22c91..116093e9 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/stack.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/stack.h
@@ -11,11 +11,12 @@
#ifndef STACK_H
#define STACK_H
-#include
#include
#include
+#include
+
#include "asc_security_core/utils/collection/collection.h"
/* Pay your attention, that this implementation is not thread safe. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/iconv.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/iconv.h
index ba73c6a4..c3473e90 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/iconv.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/iconv.h
@@ -11,10 +11,11 @@
#ifndef ICONV_H
#define ICONV_H
-#include
#include
+#include
+
typedef struct {
int code;
char *string;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ievent_loop.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ievent_loop.h
index 33417d59..fb09d95a 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ievent_loop.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ievent_loop.h
@@ -11,10 +11,11 @@
#ifndef _IEVENT_LOOP_H_
#define _IEVENT_LOOP_H_
-#include
#include
+#include
+
#define EVENT_LOOP_DEFAULT_MAX_COUNT_RUN_UNTIL 100
/**
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ifile.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ifile.h
index 5332c42a..cf277f4b 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ifile.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ifile.h
@@ -11,12 +11,13 @@
#ifndef __IFILE_H__
#define __IFILE_H__
-#include
#include
#include
#include
+#include
+
#include "asc_security_core/asc_result.h"
#include "asc_security_core/utils/istream.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/irand.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/irand.h
index 3308af39..62d9beab 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/irand.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/irand.h
@@ -11,10 +11,11 @@
#ifndef IRAND_H
#define IRAND_H
-#include
#include
+#include
+
/**
* @brief Initialize the seed for rand generator.
*/
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/istream.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/istream.h
index 309c3c40..480bcb2f 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/istream.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/istream.h
@@ -11,12 +11,13 @@
#ifndef __ISTREAM_H__
#define __ISTREAM_H__
-#include
#include
#include
#include
+#include
+
#include "asc_security_core/asc_result.h"
/**
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/itime.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/itime.h
index 26b91fed..87cbc2f5 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/itime.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/itime.h
@@ -11,10 +11,11 @@
#ifndef ITIME_H
#define ITIME_H
-#include
#include
+#include
+
#define SEC_MIN (60)
#define SEC_HOUR (SEC_MIN * 60)
#define SEC_DAY (SEC_HOUR * 24)
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/string_utils.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/string_utils.h
index a3cac6f6..7a61b3d5 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/string_utils.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/string_utils.h
@@ -11,11 +11,12 @@
#ifndef STRING_UTILS_H
#define STRING_UTILS_H
-#include
#include
#include
+#include
+
#include "asc_security_core/asc_result.h"
/**
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/uuid.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/uuid.h
index 268f8c46..ab6d7803 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/uuid.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/uuid.h
@@ -11,10 +11,10 @@
#ifndef IUUID_H
#define IUUID_H
-#include
#include
+#include
/**
* @brief Generate a binary uuid
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collector_collection.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collector_collection.c
index 21a518e6..9c927764 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collector_collection.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collector_collection.c
@@ -8,11 +8,12 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-#include
#include
#include
+#include
+
#include "asc_security_core/logger.h"
#include "asc_security_core/object_pool.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors/collector_heartbeat.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors/collector_heartbeat.c
index f41e966e..bbbd64c9 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors/collector_heartbeat.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors/collector_heartbeat.c
@@ -8,10 +8,10 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-#include
-
#include
+#include
+
#include "asc_security_core/logger.h"
#include "asc_security_core/components_manager.h"
#include "asc_security_core/core.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors_info.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors_info.c
index 2a42f0e5..35192f9a 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors_info.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors_info.c
@@ -8,11 +8,11 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-#include
-
#include
#include
+#include
+
#include "asc_security_core/logger.h"
#include "asc_security_core/object_pool.h"
#include "asc_security_core/collectors_info.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_factory.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_factory.c
index cfb4dc8f..8371594b 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_factory.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_factory.c
@@ -8,10 +8,11 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-#include
#include
+#include
+
#include "asc_security_core/components_factory_declarations.h"
#include "asc_security_core/components_manager.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_manager.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_manager.c
index 839e269d..c2900b3c 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_manager.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_manager.c
@@ -8,12 +8,12 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-#include
-
#include
#include
#include
+#include
+
#include "asc_security_core/logger.h"
#include "asc_security_core/utils/string_utils.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/core.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/core.c
index 3bc97c6a..5a6be1cb 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/core.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/core.c
@@ -8,12 +8,12 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-#include
-
#include
#include
#include
+#include
+
#include "asc_security_core/components_manager.h"
#include "asc_security_core/logger.h"
#include "asc_security_core/object_pool.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/logger.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/logger.c
index f53690a2..a9a99b33 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/logger.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/logger.c
@@ -8,14 +8,15 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
+#include
+#include
+#include
+
#include
#include "asc_security_core/components_manager.h"
// #define ASC_TIME_H_SUPPORT
#if ASC_LOG_LEVEL != LOG_LEVEL_NOTSET
-#include
-#include
-#include
#ifdef ASC_TIME_H_SUPPORT
#include
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/collector.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/collector.c
index e30ad63b..29cc2646 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/collector.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/collector.c
@@ -8,11 +8,11 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-#include
-
#include
#include
+#include
+
#include "asc_security_core/utils/itime.h"
#include "asc_security_core/logger.h"
#include "asc_security_core/components_manager.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/security_message.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/security_message.c
index 6760cbfc..880bf5d4 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/security_message.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/security_message.c
@@ -8,13 +8,12 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-
-#include
-
#include
#include
#include
+#include
+
#include "asc_security_core/model/security_message.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/object_pool_static.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/object_pool_static.c
index 0f4a85ea..6f886aac 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/object_pool_static.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/object_pool_static.c
@@ -9,12 +9,11 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-
-#include
-
#include
#include
+#include
+
#include "asc_security_core/logger.h"
#include "asc_security_core/object_pool_static.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/extensions/custom_builder_allocator.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/extensions/custom_builder_allocator.c
index 8b920a7b..a5f8c83f 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/extensions/custom_builder_allocator.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/extensions/custom_builder_allocator.c
@@ -8,10 +8,10 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-#include
-
#include
+#include
+
#include "asc_security_core/logger.h"
#include "asc_security_core/serializer/custom_builder_allocator.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.c
index 382fb59e..3d5ee06a 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.c
@@ -8,10 +8,10 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-#include
-
#include
+#include
+
#include "asc_security_core/logger.h"
#include "asc_security_core/model/schema/message_builder.h"
#include "asc_security_core/utils/uuid.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.h
index 8bfb34db..2915c008 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.h
@@ -11,11 +11,12 @@
#ifndef SERIALIZER_PRIVATE_H
#define SERIALIZER_PRIVATE_H
-#include
#include
#include
+#include
+
#include "flatcc/flatcc_builder.h"
#include "asc_security_core/utils/collection/collection.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/bit_vector.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/bit_vector.c
index ebe9840b..ed9cbdcb 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/bit_vector.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/bit_vector.c
@@ -8,12 +8,11 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-
-#include
-
#include
#include
+#include
+
#include "asc_security_core/utils/collection/bit_vector.h"
bool __bit_vector_set(char bit_vector[], int index, bool bit, int size)
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/hashtable.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/hashtable.c
index aef1efe4..2bf330b8 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/hashtable.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/hashtable.c
@@ -8,11 +8,10 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
+#include
#include
-#include
-
#include
#include
#include
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/stack.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/stack.c
index 8eb6c225..d7b94015 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/stack.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/stack.c
@@ -8,12 +8,11 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-
-#include
-
#include
#include
+#include
+
#include "asc_security_core/utils/collection/stack.h"
collection_item_t *stack_pop(stack_collection_t *stack)
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/event_loop_be.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/event_loop_be.c
index f5a55fa7..f93f6717 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/event_loop_be.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/event_loop_be.c
@@ -9,12 +9,12 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-#include
-
#include
#include
#include
+#include
+
#include "asc_security_core/logger.h"
#include "asc_security_core/object_pool.h"
#include "asc_security_core/utils/collection/list.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/iconv.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/iconv.c
index 4a304cb5..c50ea0a2 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/iconv.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/iconv.c
@@ -8,14 +8,13 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-
-#include
-
#include
#include
#include
#include
+#include
+
#include "asc_security_core/utils/string_utils.h"
#include "asc_security_core/utils/iconv.h"
#include "asc_security_core/utils/string_utils.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/string_utils.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/string_utils.c
index 37ec8161..51170665 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/string_utils.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/string_utils.c
@@ -8,13 +8,13 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-#include
-
#include
#include
#include
#include
+#include
+
#include "asc_security_core/logger.h"
#include "asc_security_core/utils/string_utils.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/uuid.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/uuid.c
index f6b379d8..f0812046 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/uuid.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/uuid.c
@@ -8,14 +8,13 @@
/* and in the root directory of this software. */
/* */
/*******************************************************************************/
-
-#include
-
#include
#include
#include
#include
+#include
+
#include "asc_security_core/utils/irand.h"
#include "asc_security_core/utils/uuid.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/nx_azure_iot_security_module.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/nx_azure_iot_security_module.c
index f2b4f0c5..9acc642d 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/nx_azure_iot_security_module.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/nx_azure_iot_security_module.c
@@ -8,12 +8,11 @@
/* and in the root directory of this software. */
/* */
/**************************************************************************/
-
-#include
-
#include
#include
+#include
+
#include "nx_azure_iot_hub_client.h"
#include "nx_azure_iot_security_module.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/model/objects/object_network_activity_ext.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/model/objects/object_network_activity_ext.c
index 3f0f4168..5dcd82bf 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/model/objects/object_network_activity_ext.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/model/objects/object_network_activity_ext.c
@@ -8,11 +8,10 @@
/* and in the root directory of this software. */
/* */
/**************************************************************************/
+#include
#include
-#include
-
#include "nx_api.h"
#include "nx_ip.h"
#include "nx_ipv6.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/utils/itime.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/utils/itime.c
index 2a30d7cf..7fbe0e43 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/utils/itime.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/utils/itime.c
@@ -8,11 +8,10 @@
/* and in the root directory of this software. */
/* */
/**************************************************************************/
+#include
#include
-#include
-
#include "asc_security_core/utils/itime.h"
static unix_time_callback_t _time_callback = NULL;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/README.md b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/README.md
deleted file mode 100644
index be8207a5..00000000
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/README.md
+++ /dev/null
@@ -1,124 +0,0 @@
-# Azure IoT Middleware for Azure RTOS
-
-Azure IoT Middleware for Azure RTOS is a platform specific library that acts as a binding layer between the Azure RTOS and the [Azure SDK for Embedded C](https://github.com/Azure/azure-sdk-for-c/tree/master/sdk/docs/iot). Goals of this layer are following:
-
-* Expose smart client interfaces (IoTHub_Client, DeviceProvisioning_Client) for the customers, to be consumed in their application.
-* Orchestrate the interaction between Embedded C SDK and platform.
-* Provide Azure RTOS platform initialization.
-* [IoT Plug and Play](https://docs.microsoft.com/azure/iot-develop/overview-iot-plug-and-play) support.
-* Security capabilities.
-* Resource limitation aware.
-* Protocol support.
-
-## Getting Started
-
-Azure IoT Middleware for Azure RTOS stays as an addon for the Azure RTOS NetXDuo. It facilitates the MQTT and TLS stacks that have been provided in the NetXDuo.
-
-
-
-### Build
-
-The Azure IoT Middleware for Azure RTOS is built as part of the NetXDuo. Make sure you have defined the following *marcos* when building it:
-
-Module | Marcos |
-| --- | --- |
-| Azure IoT Middleware for Azure RTOS | `NX_ENABLE_EXTENDED_NOTIFY_SUPPORT`
`NX_SECURE_ENABLE`
`NXD_MQTT_CLOUD_ENABLE`
-| Azure Defender for IoT security module | `NX_ENABLE_IP_PACKET_FILTER`
-
-**NOTE:** Azure Defender for IoT security module is enabled by default. You can define `NX_AZURE_DISABLE_IOT_SECURITY_MODULE` to disable it. [Learn more](#azure-defender-for-iot-security-module).
-
-Follow [this example](/ports/cortex_m7/iar/inc/nx_port.h) to see how to define these *marcos* in the header file.
-
-### Samples
-
-For complete samples on how to get started on different devices with Azure IoT Middleware for Azure RTOS, see the following samples:
-
-Manufacturer | Device | Samples |
-| --- | --- | --- |
-| Microchip | [ATSAME54-XPRO](https://www.microchip.com/developmenttools/productdetails/atsame54-xpro) | [GCC/CMake](https://github.com/azure-rtos/getting-started/tree/master/Microchip/ATSAME54-XPRO) • [IAR](https://aka.ms/azrtos-sample/e54-iar) • [MPLAB](https://aka.ms/azrtos-sample/e54-mplab)
-| MXCHIP | [AZ3166](https://aka.ms/iot-devkit) | [GCC/CMake](https://github.com/azure-rtos/getting-started/tree/master/MXChip/AZ3166)
-| NXP | [MIMXRT1060-EVK](https://www.nxp.com/design/development-boards/i-mx-evaluation-and-development-boards/mimxrt1060-evk-i-mx-rt1060-evaluation-kit:MIMXRT1060-EVK) | [GCC/CMake](https://github.com/azure-rtos/getting-started/tree/master/NXP/MIMXRT1060-EVK) • [IAR](https://aka.ms/azrtos-sample/rt1060-iar) • [MCUXpresso](https://aka.ms/azrtos-sample/rt1060-mcuxpresso)
-| STMicroelectronics | [STM32F746GDISCOVERY](https://www.st.com/en/evaluation-tools/32f746gdiscovery.html) | [IAR](https://aka.ms/azrtos-sample/f746g-iar) • [STM32Cube](https://aka.ms/azrtos-sample/f746g-cubeide)
-| STMicroelectronics | [B-L4S5I-IOT01](https://www.st.com/en/evaluation-tools/b-l4s5i-iot01a.html) / [B-L475E-IOT01](https://www.st.com/en/evaluation-tools/b-l475e-iot01a.html) | [GCC/CMake](https://github.com/azure-rtos/getting-started/tree/master/STMicroelectronics/STM32L4_L4%2B) • [IAR](https://aka.ms/azrtos-sample/l4s5-iar) • [STM32Cube](https://aka.ms/azrtos-sample/l4s5-cubeide)
-| Renesas | [RX65N-RSK-2MB](https://www.renesas.com/us/en/products/microcontrollers-microprocessors/rx-32-bit-performance-efficiency-mcus/rx65n-2mb-starter-kit-plus-renesas-starter-kit-rx65n-2mb) | [GCC/CMake](https://github.com/azure-rtos/getting-started/tree/master/Renesas/RSK_RX65N_2MB) • [IAR](https://aka.ms/azrtos-samples/rx65n-rsk-2mb-iar) • [E2Studio CCRX](https://aka.ms/azrtos-samples/rx65n-rsk-2mb-ccrx) • [E2Studio GNURX](https://aka.ms/azrtos-samples/rx65n-rsk-2mb-gnurx)
-| Renesas | [RX65N-Cloud-Kit](https://www.renesas.com/us/en/products/microcontrollers-microprocessors/rx-32-bit-performance-efficiency-mcus/rx65n-cloud-kit-renesas-rx65n-cloud-kit) | [E2Studio CCRX](https://aka.ms/azrtos-samples/rx65n-ck-ccrx) • [E2Studio GNURX](https://aka.ms/azrtos-samples/rx65n-ck-gnurx)
-
-## Features
-
-Basic features provided by [Azure SDK for Embedded C](https://github.com/Azure/azure-sdk-for-c/tree/master/sdk/docs/iot):
-* Connect to IoTHub via MQTT.
-* APIs following the IoT Plug and Play convention to implement Telemetry, Commands, Properties and Components defined in a DTDL model.
-* Send device to cloud (D2C) message.
-* Receive cloud to device (C2D) message.
-* Device Twins.
-* Receive direct method.
-* Authentication: SAS Token.
-
-Enhanced features provided in middleware:
-* Authentication: X.509 client certificate.
-* Device Provisioning Service.
-* JSON parser.
-
-## Azure Defender for IoT
-
-The [Azure Defender for IoT](https://docs.microsoft.com/azure/defender-for-iot/iot-security-azure-rtos) provides a comprehensive security solution for Azure RTOS devices. The middleware ships with the ASC for IoT Security Module built-in and enabled by default to detect common threats and potential malicious activities.
-
-### Opt-out
-
-To disable (opt-out) the module for your application, you can choose one of these two options:
-* Define `NX_AZURE_DISABLE_IOT_SECURITY_MODULE` in NetXDuo header file such as [`nx_port.h`](/ports/cortex_m7/iar/inc/nx_port.h) when building the middleware.
-* Call [`UINT nx_azure_iot_security_module_disable(NX_AZURE_IOT *nx_azure_iot_ptr)`](https://docs.microsoft.com/azure/defender-for-iot/azure-rtos-security-module-api#disable-azure-iot-security-module) in your application code.
-
-### Data collection
-
-By enabling the module, it analyzes inbound and outbound network activity on IPv4 and IPv6 supported protocols:
-* TCP
-* UDP
-* ICMP
-
-And with below data collected:
-* Local and remote address
-* Local and remote port
-* Bytes in
-* Bytes out
-
-### Resource requirements:
-
-ASC for IoT module leverages existing Azure RTOS resources, and sends security messages in the background, without interfering with the user application, using the same connection to the IoT Hub.
-
-The extra resource it will take on device and connection:
-
-**Memory Footprint** (using default config - 4 unique monitored connection in IPv4 in an hour):
-Toolchain | RAM | ROM |
-| --- | --- | --- |
-| IAR Embedded Workbench (iccarm) | 4Kb | 10Kb
-| GUN ARM Embedded Toolchain (arm-gcc) | 4Kb | 13Kb
-
-**Additional Connection**:
-Connection Type | RAM | Network |
-| --- | --- | --- |
-| IPv4 | 52bytes | 36bytes
-| IPv6 | 200bytes | 60bytes
-
-So the total additional connection traffic will be:
-*Total (in bytes) = Metadata (e.g. 300 bytes) + IPv4 Connections * 36 + IPv6 Connections * 60*
-
-Learn [here](https://docs.microsoft.com/en-us/azure/defender-for-iot) for more information about Azure Defender for IoT.
-
-## APIs
-
-* [nx_azure_iot](./azure_rtos_iot.md)
-* [nx_azure_iot_hub_client](./azure_rtos_iot_hub_client.md)
-* [nx_azure_iot_hub_client_properties](./azure_rtos_iot_hub_client_properties.md)
-* [nx_azure_iot_provisioning_client](./azure_rtos_iot_provisioning_client.md)
-* [nx_azure_iot_json](./azure_rtos_iot_json.md)
-* [nx_azure_iot_security_module](../azure_iot_security_module/docs/nx_azure_iot_security_module.md)
-
-## Need Help?
-
-* File an issue via [Github Issues](https://github.com/azure-rtos/netxduo/issues/new/choose).
-* Check [previous questions](https://stackoverflow.com/questions/tagged/azure-rtos+netxduo) or ask new ones on StackOverflow using the [azure-rtos](https://stackoverflow.com/questions/tagged/azure-rtos) and [netxduo](https://stackoverflow.com/questions/tagged/netxduo) tags.
-
-## Licensing
-
-View [Licensing](https://github.com/azure-rtos/netxduo#licensing) of Azure RTOS NetXDuo.
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/azure_rtos_iot_hub_client.md b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/azure_rtos_iot_hub_client.md
index 5323cbf6..67144460 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/azure_rtos_iot_hub_client.md
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/azure_rtos_iot_hub_client.md
@@ -11,6 +11,7 @@
* [nx_azure_iot_hub_client_trusted_cert_add](#nx_azure_iot_hub_client_trusted_cert_add)
* [nx_azure_iot_hub_client_device_cert_set](#nx_azure_iot_hub_client_device_cert_set)
* [nx_azure_iot_hub_client_symmetric_key_set](#nx_azure_iot_hub_client_symmetric_key_set)
+* [nx_azure_iot_hub_client_websocket_enable](#nx_azure_iot_hub_client_websocket_enable)
* [nx_azure_iot_hub_client_connect](#nx_azure_iot_hub_client_connect)
* [nx_azure_iot_hub_client_disconnect](#nx_azure_iot_hub_client_disconnect)
* [nx_azure_iot_hub_client_connection_status_callback_set](#nx_azure_iot_hub_client_connection_status_callback_set)
@@ -328,6 +329,39 @@ Threads
+#### **nx_azure_iot_hub_client_websocket_enable**
+***
+ Enables MQTT over WebSocket to connect to IoT Hub
+
+**Prototype**
+```c
+UINT nx_azure_iot_hub_client_websocket_enable(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr);
+```
+**Description**
+
+This routine enables MQTT over WebSocket to connect to the Azure IoT Hub.
+
+**Parameters**
+
+| Name | Description |
+| - |:-|
+| hub_client_ptr [in] | A pointer to a `NX_AZURE_IOT_HUB_CLIENT` |
+
+
+**Return Values**
+* NX_AZURE_IOT_SUCCESS Successful if MQTT over Websocket is enabled.
+* NX_AZURE_IOT_INVALID_PARAMETER Fail to enable MQTT over WebSocket due to invalid parameter.
+
+**Allowed From**
+
+Threads
+
+**Example**
+
+**See Also**
+
+
+
#### **nx_azure_iot_hub_client_connect**
***
Connects to IoT Hub
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/img/iothub_configuration.png b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/img/iothub_configuration.png
deleted file mode 100644
index 4ffeb0ad..00000000
Binary files a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/img/iothub_configuration.png and /dev/null differ
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.c
index a58a44b4..06bfcf68 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.c
@@ -10,14 +10,15 @@
/**************************************************************************/
/* Version: 6.1 */
+#include
+#include
+
-#include "nx_azure_iot.h"
#ifndef NX_AZURE_DISABLE_IOT_SECURITY_MODULE
#include "nx_azure_iot_security_module.h"
#endif /* NX_AZURE_DISABLE_IOT_SECURITY_MODULE */
-#include
-#include
+#include "nx_azure_iot.h"
#include "azure/core/internal/az_log_internal.h"
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.h
index 24feea38..beee5e74 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.h
@@ -142,6 +142,7 @@ UINT nx_azure_iot_log(UCHAR *type_ptr, UINT type_len, UCHAR *msg_ptr, UINT msg_l
#define NX_AZURE_IOT_EMPTY_JSON 0x20016
#define NX_AZURE_IOT_SAS_TOKEN_EXPIRED 0x20017
+#define NX_AZURE_IOT_NO_MORE_ENTRIES 0x20018
/* Resource type managed by AZ_IOT. */
#define NX_AZURE_IOT_RESOURCE_IOT_HUB 0x1
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.c
index 534381a3..c10323da 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.c
@@ -50,6 +50,8 @@ static UCHAR _nx_azure_iot_hub_client_user_agent[] = NX_AZURE_IOT_HUB_CLIENT_USE
#define NX_AZURE_IOT_HUB_CLIENT_COMPONENT_STRING "$.sub"
+#define NX_AZURE_IOT_HUB_CLIENT_WEB_SOCKET_PATH "/$iothub/websocket"
+
static VOID nx_azure_iot_hub_client_received_message_cleanup(NX_AZURE_IOT_HUB_CLIENT_RECEIVE_MESSAGE *message);
static UINT nx_azure_iot_hub_client_cloud_message_sub_unsub(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr,
UINT is_subscribe);
@@ -351,6 +353,25 @@ ULONG index;
}
#endif /* NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_UPDATE */
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+UINT nx_azure_iot_hub_client_websocket_enable(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr)
+{
+NX_AZURE_IOT_RESOURCE *resource_ptr;
+
+ if (hub_client_ptr == NX_NULL)
+ {
+ LogError(LogLiteralArgs("IoTHub WebSocket enable fail: INVALID POINTER"));
+ return(NX_AZURE_IOT_INVALID_PARAMETER);
+ }
+
+ /* Set resource pointer. */
+ resource_ptr = &(hub_client_ptr -> nx_azure_iot_hub_client_resource);
+
+ return(nxd_mqtt_client_websocket_set(&(resource_ptr -> resource_mqtt), (UCHAR *)resource_ptr -> resource_hostname, resource_ptr -> resource_hostname_length,
+ (UCHAR *)NX_AZURE_IOT_HUB_CLIENT_WEB_SOCKET_PATH, sizeof(NX_AZURE_IOT_HUB_CLIENT_WEB_SOCKET_PATH) - 1));
+}
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
UINT nx_azure_iot_hub_client_connect(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr,
UINT clean_session, UINT wait_option)
{
@@ -364,6 +385,7 @@ VOID *buffer_context;
UINT buffer_length;
ULONG expiry_time_secs;
az_result core_result;
+UINT server_port;
/* Check for invalid input pointers. */
if ((hub_client_ptr == NX_NULL) || (hub_client_ptr -> nx_azure_iot_ptr == NX_NULL))
@@ -530,8 +552,21 @@ az_result core_result;
/* Release the mutex. */
tx_mutex_put(hub_client_ptr -> nx_azure_iot_ptr -> nx_azure_iot_mutex_ptr);
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+ if (mqtt_client_ptr -> nxd_mqtt_client_use_websocket == NX_TRUE)
+ {
+ server_port = NXD_MQTT_OVER_WEBSOCKET_TLS_PORT;
+ }
+ else
+ {
+ server_port = NXD_MQTT_TLS_PORT;
+ }
+#else
+ server_port = NXD_MQTT_TLS_PORT;
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
/* Start MQTT connection. */
- status = nxd_mqtt_client_secure_connect(mqtt_client_ptr, &server_address, NXD_MQTT_TLS_PORT,
+ status = nxd_mqtt_client_secure_connect(mqtt_client_ptr, &server_address, server_port,
nx_azure_iot_mqtt_tls_setup, NX_AZURE_IOT_MQTT_KEEP_ALIVE,
clean_session, wait_option);
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.h
index bbac0862..4ff16d59 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.h
@@ -279,6 +279,21 @@ UINT nx_azure_iot_hub_client_component_add(NX_AZURE_IOT_HUB_CLIENT *hub_client_p
const UCHAR *component_name_ptr,
USHORT component_name_length);
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+/**
+ * @brief Enable using MQTT over WebSocket to connect to IoTHub.
+ *
+ * @param[in] hub_client_ptr A pointer to a #NX_AZURE_IOT_HUB_CLIENT.
+ * @return A `UINT` with the result of the API.
+ * @retval #NX_AZURE_IOT_SUCCESS Successful if MQTT over WebSocket is enabled.
+ * @retval #NX_AZURE_IOT_INVALID_PARAMETER Fail to enable C2D message receiving due to invalid parameter.
+ * @retval NXD_MQTT_NOT_CONNECTED Fail to enable C2D message receiving due to MQTT not connected.
+ * @retval NXD_MQTT_PACKET_POOL_FAILURE Fail to enable C2D message receiving due to no available packet in pool.
+ * @retval NXD_MQTT_COMMUNICATION_FAILURE Fail to enable C2D message receiving due to TCP/TLS error.
+ */
+UINT nx_azure_iot_hub_client_websocket_enable(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr);
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
/**
* @brief Connect to IoT Hub.
*
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client_properties.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client_properties.c
index b8ed4ef3..cd1740aa 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client_properties.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client_properties.c
@@ -187,7 +187,7 @@ UINT system_component;
return(NX_AZURE_IOT_INVALID_PARAMETER);
}
- component_name = az_span_create((UCHAR *)component_name_pptr, (INT)*component_name_length_ptr);
+ component_name = az_span_create((UCHAR *)*component_name_pptr, (INT)*component_name_length_ptr);
core_message_type = (message_type == NX_AZURE_IOT_HUB_PROPERTIES) ? AZ_IOT_HUB_CLIENT_PROPERTIES_MESSAGE_TYPE_GET_RESPONSE :
AZ_IOT_HUB_CLIENT_PROPERTIES_MESSAGE_TYPE_WRITABLE_UPDATED;
core_property_type = (property_type == NX_AZURE_IOT_HUB_CLIENT_PROPERTY_REPORTED_FROM_DEVICE) ? AZ_IOT_HUB_CLIENT_PROPERTY_REPORTED_FROM_DEVICE :
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.c
index 381be453..9cc94f97 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.c
@@ -33,6 +33,8 @@
#define NX_AZURE_IOT_PROVISIONING_CLIENT_PAYLOAD_END "}"
#define NX_AZURE_IOT_PROVISIONING_CLIENT_POLICY_NAME "registration"
+#define NX_AZURE_IOT_PROVISIONING_CLIENT_WEB_SOCKET_PATH "/$iothub/websocket"
+
/* Set the default retry to Provisioning service. */
#ifndef NX_AZURE_IOT_PROVISIONING_CLIENT_DEFAULT_RETRY
#define NX_AZURE_IOT_PROVISIONING_CLIENT_DEFAULT_RETRY (3)
@@ -134,6 +136,7 @@ UINT status;
NXD_ADDRESS server_address;
NXD_MQTT_CLIENT *mqtt_client_ptr;
NX_AZURE_IOT_RESOURCE *resource_ptr;
+UINT server_port;
/* Resolve the host name. */
status = nxd_dns_host_by_name_get(prov_client_ptr -> nx_azure_iot_ptr -> nx_azure_iot_dns_ptr,
@@ -161,8 +164,21 @@ NX_AZURE_IOT_RESOURCE *resource_ptr;
return(status);
}
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+ if (mqtt_client_ptr -> nxd_mqtt_client_use_websocket == NX_TRUE)
+ {
+ server_port = NXD_MQTT_OVER_WEBSOCKET_TLS_PORT;
+ }
+ else
+ {
+ server_port = NXD_MQTT_TLS_PORT;
+ }
+#else
+ server_port = NXD_MQTT_TLS_PORT;
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
/* Start MQTT connection. */
- status = nxd_mqtt_client_secure_connect(mqtt_client_ptr, &server_address, NXD_MQTT_TLS_PORT,
+ status = nxd_mqtt_client_secure_connect(mqtt_client_ptr, &server_address, server_port,
nx_azure_iot_mqtt_tls_setup, NX_AZURE_IOT_MQTT_KEEP_ALIVE,
NX_FALSE, wait_option);
@@ -1091,6 +1107,24 @@ NX_AZURE_IOT_RESOURCE *resource_ptr;
}
}
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+UINT nx_azure_iot_provisioning_client_websocket_enable(NX_AZURE_IOT_PROVISIONING_CLIENT *prov_client_ptr)
+{
+NX_AZURE_IOT_RESOURCE *resource_ptr;
+
+ if (prov_client_ptr == NX_NULL)
+ {
+ LogError(LogLiteralArgs("IoTProvisioning client WebSocket enable fail: INVALID POINTER"));
+ return(NX_AZURE_IOT_INVALID_PARAMETER);
+ }
+
+ /* Set resource pointer. */
+ resource_ptr = &(prov_client_ptr -> nx_azure_iot_provisioning_client_resource);
+
+ return(nxd_mqtt_client_websocket_set(&(resource_ptr -> resource_mqtt), (UCHAR *)resource_ptr -> resource_hostname, resource_ptr -> resource_hostname_length,
+ (UCHAR *)NX_AZURE_IOT_PROVISIONING_CLIENT_WEB_SOCKET_PATH, sizeof(NX_AZURE_IOT_PROVISIONING_CLIENT_WEB_SOCKET_PATH) - 1));
+}
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
static VOID nx_azure_iot_provisioning_client_event_process(NX_AZURE_IOT *nx_azure_iot_ptr,
ULONG common_events, ULONG module_own_events)
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.h
index 65630bfe..01d88dbc 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.h
@@ -200,6 +200,18 @@ UINT nx_azure_iot_provisioning_client_device_cert_set(NX_AZURE_IOT_PROVISIONING_
UINT nx_azure_iot_provisioning_client_symmetric_key_set(NX_AZURE_IOT_PROVISIONING_CLIENT *prov_client_ptr,
const UCHAR *symmetric_key, UINT symmetric_key_length);
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+/**
+ * @brief Enable using MQTT over WebSocket to register device to Azure IoT Provisioning service.
+ *
+ * @param[in] prov_client_ptr A pointer to a #NX_AZURE_IOT_PROVISIONING_CLIENT.
+ * @return A `UINT` with the result of the API.
+ * @retval #NX_AZURE_IOT_SUCCESS Successful if MQTT over WebSocket is enabled.
+ * @retval #NX_AZURE_IOT_INVALID_PARAMETER Fail to enable MQTT over WebSocket due to invalid parameter.
+ */
+UINT nx_azure_iot_provisioning_client_websocket_enable(NX_AZURE_IOT_PROVISIONING_CLIENT *prov_client_ptr);
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
/**
* @brief Register device to Azure IoT Provisioning service.
* @details This routine registers device to Azure IoT Provisioning service.
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcp_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcp_client.c
index 750c2762..e7131477 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcp_client.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcp_client.c
@@ -154,7 +154,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_create PORTABLE C */
-/* 6.1.10 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -210,6 +210,10 @@ UINT status;
/* 01-31-2022 Yuxin Zhou Modified comment(s), supported*/
/* multiple client instances, */
/* resulting in version 6.1.10 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), cleaned */
+/* up error check logic, and */
+/* properly terminated thread, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_dhcp_create(NX_DHCP *dhcp_ptr, NX_IP *ip_ptr, CHAR *name_ptr)
@@ -327,16 +331,8 @@ UINT label_length = 0;
}
/* Create the pool and check the status */
- status = nx_packet_pool_create(&dhcp_ptr -> nx_dhcp_pool, "NetX DHCP Client", NX_DHCP_PACKET_PAYLOAD,
- dhcp_ptr -> nx_dhcp_pool_area, NX_DHCP_PACKET_POOL_SIZE);
-
- /* Determine if it was successful. */
- if (status != NX_SUCCESS)
- {
-
- /* No, return error status. */
- return(status);
- }
+ nx_packet_pool_create(&dhcp_ptr -> nx_dhcp_pool, "NetX DHCP Client", NX_DHCP_PACKET_PAYLOAD,
+ dhcp_ptr -> nx_dhcp_pool_area, NX_DHCP_PACKET_POOL_SIZE);
/* Set an internal packet pool pointer to the newly created packet pool. */
dhcp_ptr -> nx_dhcp_packet_pool_ptr = &dhcp_ptr -> nx_dhcp_pool;
@@ -350,39 +346,11 @@ UINT label_length = 0;
#endif /* NX_DHCP_CLIENT_USER_CREATE_PACKET_POOL */
/* Create the Socket and check the status */
- status = nx_udp_socket_create(ip_ptr, &(dhcp_ptr -> nx_dhcp_socket), "NetX DHCP Client",
- NX_DHCP_TYPE_OF_SERVICE, NX_DHCP_FRAGMENT_OPTION, NX_DHCP_TIME_TO_LIVE, NX_DHCP_QUEUE_DEPTH);
-
- /* Was the socket creation successful? */
- if (status != NX_SUCCESS)
- {
-
-#ifndef NX_DHCP_CLIENT_USER_CREATE_PACKET_POOL
- /* Delete the packet pool. */
- nx_packet_pool_delete(dhcp_ptr -> nx_dhcp_packet_pool_ptr);
-#endif
-
- /* No, return error status. */
- return(status);
- }
-
+ nx_udp_socket_create(ip_ptr, &(dhcp_ptr -> nx_dhcp_socket), "NetX DHCP Client",
+ NX_DHCP_TYPE_OF_SERVICE, NX_DHCP_FRAGMENT_OPTION, NX_DHCP_TIME_TO_LIVE, NX_DHCP_QUEUE_DEPTH);
/* Set the UDP socket receive callback function. */
- status = nx_udp_socket_receive_notify(&(dhcp_ptr -> nx_dhcp_socket), _nx_dhcp_udp_receive_notify);
-
- /* Check status. */
- if (status != NX_SUCCESS)
- {
-
-
-#ifndef NX_DHCP_CLIENT_USER_CREATE_PACKET_POOL
- /* Delete the packet pool. */
- nx_packet_pool_delete(dhcp_ptr -> nx_dhcp_packet_pool_ptr);
-#endif
-
- /* Delete the UDP socket. */
- nx_udp_socket_delete(&(dhcp_ptr -> nx_dhcp_socket));
- }
+ nx_udp_socket_receive_notify(&(dhcp_ptr -> nx_dhcp_socket), _nx_dhcp_udp_receive_notify);
dhcp_ptr -> nx_dhcp_socket.nx_udp_socket_reserved_ptr = (VOID*)dhcp_ptr;
@@ -468,6 +436,9 @@ UINT label_length = 0;
if (status != TX_SUCCESS)
{
+ /* First put the thread into TERMINATE state. */
+ tx_thread_terminate(&(dhcp_ptr -> nx_dhcp_thread));
+
/* Delete the thread. */
tx_thread_delete(&(dhcp_ptr -> nx_dhcp_thread));
@@ -1173,7 +1144,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_interface_reinitialize PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -1219,6 +1190,9 @@ UINT status;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_dhcp_interface_reinitialize(NX_DHCP *dhcp_ptr, UINT iface_index)
@@ -1250,10 +1224,10 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
{
/* Get the IP address. */
- status = nx_ip_interface_address_get(dhcp_ptr -> nx_dhcp_ip_ptr, iface_index, &ip_address, &network_mask);
+ nx_ip_interface_address_get(dhcp_ptr -> nx_dhcp_ip_ptr, iface_index, &ip_address, &network_mask);
/* Check if the IP address is set by DHCP. */
- if ((status == NX_SUCCESS) && (ip_address == interface_record -> nx_dhcp_ip_address))
+ if (ip_address == interface_record -> nx_dhcp_ip_address)
{
/* Clear the IP address. */
@@ -2352,7 +2326,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_interface_decline PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -2392,13 +2366,15 @@ UINT status;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_dhcp_interface_decline(NX_DHCP *dhcp_ptr, UINT iface_index)
{
UINT status;
-UINT original_state;
NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
@@ -2426,9 +2402,6 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
return(NX_DHCP_NOT_BOUND);
}
- /* Get the original state. */
- original_state = interface_record -> nx_dhcp_state;
-
/* Send the decline DHCP request. */
_nx_dhcp_send_request_internal(dhcp_ptr, interface_record, NX_DHCP_TYPE_DHCPDECLINE);
@@ -2444,25 +2417,20 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
/* Set the retransmission interval. */
interface_record -> nx_dhcp_rtr_interval = 0;
- /* Check if the state is changed. */
- if (original_state != interface_record -> nx_dhcp_state)
+ /* Determine if the application has specified a routine for DHCP state change notification. */
+ if (dhcp_ptr -> nx_dhcp_state_change_callback)
{
- /* Determine if the application has specified a routine for DHCP state change notification. */
- if (dhcp_ptr -> nx_dhcp_state_change_callback)
- {
-
- /* Yes, call the application's state change notify function with the new state. */
- (dhcp_ptr -> nx_dhcp_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_state);
- }
+ /* Yes, call the application's state change notify function with the new state. */
+ (dhcp_ptr -> nx_dhcp_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_state);
+ }
- /* Determine if the application has specified a routine for DHCP interface state change notification. */
- if (dhcp_ptr -> nx_dhcp_interface_state_change_callback)
- {
+ /* Determine if the application has specified a routine for DHCP interface state change notification. */
+ if (dhcp_ptr -> nx_dhcp_interface_state_change_callback)
+ {
- /* Yes, call the application's state change notify function with the new state. */
- (dhcp_ptr -> nx_dhcp_interface_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_interface_index, interface_record -> nx_dhcp_state);
- }
+ /* Yes, call the application's state change notify function with the new state. */
+ (dhcp_ptr -> nx_dhcp_interface_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_interface_index, interface_record -> nx_dhcp_state);
}
/* Release the DHCP mutex. */
@@ -2680,7 +2648,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_interface_release PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -2721,13 +2689,16 @@ UINT status;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_dhcp_interface_release(NX_DHCP *dhcp_ptr, UINT iface_index)
{
UINT i;
-UINT status, original_state;
+UINT status;
NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
@@ -2758,34 +2729,26 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
return(NX_DHCP_NOT_BOUND);
}
- /* Get the original state. */
- original_state = interface_record -> nx_dhcp_state;
-
/* Send the release DHCP request. */
_nx_dhcp_send_request_internal(dhcp_ptr, interface_record, NX_DHCP_TYPE_DHCPRELEASE);
- /* Reinitialize DHCP. */
+ /* Reinitialize DHCP. Note: the state is changed to NX_DHCP_STATE_NOT_STARTED in this function. */
_nx_dhcp_interface_reinitialize(dhcp_ptr, iface_index);
- /* Check if the state is changed. */
- if (original_state != interface_record -> nx_dhcp_state)
+ /* Determine if the application has specified a routine for DHCP state change notification. */
+ if (dhcp_ptr -> nx_dhcp_state_change_callback)
{
- /* Determine if the application has specified a routine for DHCP state change notification. */
- if (dhcp_ptr -> nx_dhcp_state_change_callback)
- {
-
- /* Yes, call the application's state change notify function with the new state. */
- (dhcp_ptr -> nx_dhcp_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_state);
- }
+ /* Yes, call the application's state change notify function with the new state. */
+ (dhcp_ptr -> nx_dhcp_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_state);
+ }
- /* Determine if the application has specified a routine for DHCP interface state change notification. */
- if (dhcp_ptr -> nx_dhcp_interface_state_change_callback)
- {
+ /* Determine if the application has specified a routine for DHCP interface state change notification. */
+ if (dhcp_ptr -> nx_dhcp_interface_state_change_callback)
+ {
- /* Yes, call the application's state change notify function with the new state. */
- (dhcp_ptr -> nx_dhcp_interface_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_interface_index, interface_record -> nx_dhcp_state);
- }
+ /* Yes, call the application's state change notify function with the new state. */
+ (dhcp_ptr -> nx_dhcp_interface_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_interface_index, interface_record -> nx_dhcp_state);
}
/* Check if other interfaces are running DHCP. */
@@ -2805,20 +2768,15 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
return(NX_SUCCESS);
}
}
-
- /* Has DHCP stopped on all interfaces? */
- if (i == NX_DHCP_CLIENT_MAX_RECORDS)
- {
-
- /* Yes, stop DHCP Thread. */
- tx_thread_suspend(&(dhcp_ptr -> nx_dhcp_thread));
+
+ /* Yes, stop DHCP Thread. */
+ tx_thread_suspend(&(dhcp_ptr -> nx_dhcp_thread));
- /* Deactivate DHCP Timer. */
- tx_timer_deactivate(&(dhcp_ptr -> nx_dhcp_timer));
+ /* Deactivate DHCP Timer. */
+ tx_timer_deactivate(&(dhcp_ptr -> nx_dhcp_timer));
- /* Unbind UDP socket. */
- nx_udp_socket_unbind(&(dhcp_ptr -> nx_dhcp_socket));
- }
+ /* Unbind UDP socket. */
+ nx_udp_socket_unbind(&(dhcp_ptr -> nx_dhcp_socket));
/* Release the DHCP mutex. */
tx_mutex_put(&(dhcp_ptr -> nx_dhcp_mutex));
@@ -4061,7 +4019,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_interface_stop PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -4107,6 +4065,9 @@ UINT status;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_dhcp_interface_stop(NX_DHCP *dhcp_ptr, UINT iface_index)
@@ -4114,7 +4075,6 @@ UINT _nx_dhcp_interface_stop(NX_DHCP *dhcp_ptr, UINT iface_index)
UINT i;
UINT status;
-UINT original_state;
NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
@@ -4133,9 +4093,6 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
return(status);
}
- /* Get the original state. */
- original_state = interface_record -> nx_dhcp_state;
-
/* Determine if DHCP is started. */
if (interface_record -> nx_dhcp_state == NX_DHCP_STATE_NOT_STARTED)
{
@@ -4150,25 +4107,20 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
/* Set the state to NX_DHCP_STATE_NOT_STARTED. */
interface_record -> nx_dhcp_state = NX_DHCP_STATE_NOT_STARTED;
- /* Check if the state is changed. */
- if (original_state != interface_record -> nx_dhcp_state)
+ /* Determine if the application has specified a routine for DHCP state change notification. */
+ if (dhcp_ptr -> nx_dhcp_state_change_callback)
{
- /* Determine if the application has specified a routine for DHCP state change notification. */
- if (dhcp_ptr -> nx_dhcp_state_change_callback)
- {
-
- /* Yes, call the application's state change notify function with the new state. */
- (dhcp_ptr -> nx_dhcp_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_state);
- }
+ /* Yes, call the application's state change notify function with the new state. */
+ (dhcp_ptr -> nx_dhcp_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_state);
+ }
- /* Determine if the application has specified a routine for DHCP interface state change notification. */
- if (dhcp_ptr -> nx_dhcp_interface_state_change_callback)
- {
+ /* Determine if the application has specified a routine for DHCP interface state change notification. */
+ if (dhcp_ptr -> nx_dhcp_interface_state_change_callback)
+ {
- /* Yes, call the application's state change notify function with the new state. */
- (dhcp_ptr -> nx_dhcp_interface_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_interface_index, interface_record->nx_dhcp_state);
- }
+ /* Yes, call the application's state change notify function with the new state. */
+ (dhcp_ptr -> nx_dhcp_interface_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_interface_index, interface_record->nx_dhcp_state);
}
/* Check if other interfaces are running DHCP. */
@@ -4188,20 +4140,15 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
return(NX_SUCCESS);
}
}
-
- /* Has DHCP stopped on all interfaces? */
- if (i == NX_DHCP_CLIENT_MAX_RECORDS)
- {
- /* Yes, stop DHCP Thread. */
- tx_thread_suspend(&(dhcp_ptr -> nx_dhcp_thread));
+ /* Yes, stop DHCP Thread. */
+ tx_thread_suspend(&(dhcp_ptr -> nx_dhcp_thread));
- /* Deactivate DHCP Timer. */
- tx_timer_deactivate(&(dhcp_ptr -> nx_dhcp_timer));
+ /* Deactivate DHCP Timer. */
+ tx_timer_deactivate(&(dhcp_ptr -> nx_dhcp_timer));
- /* Unbind UDP socket. */
- nx_udp_socket_unbind(&(dhcp_ptr -> nx_dhcp_socket));
- }
+ /* Unbind UDP socket. */
+ nx_udp_socket_unbind(&(dhcp_ptr -> nx_dhcp_socket));
/* Release the DHCP mutex. */
tx_mutex_put(&(dhcp_ptr->nx_dhcp_mutex));
@@ -5290,7 +5237,7 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_packet_process PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -5340,6 +5287,9 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
VOID _nx_dhcp_packet_process(NX_DHCP *dhcp_ptr, NX_DHCP_INTERFACE_RECORD *interface_record, NX_PACKET *packet_ptr)
@@ -5407,20 +5357,7 @@ ULONG probing_delay;
/* Initialize the offset to the beginning of the packet buffer. */
offset = 0;
status = nx_packet_data_extract_offset(packet_ptr, offset, (VOID *)new_packet_ptr -> nx_packet_prepend_ptr, (packet_ptr) -> nx_packet_length, &bytes_copied);
-
- /* Check status. */
- if ((status != NX_SUCCESS) || (bytes_copied == 0))
- {
-
- /* Release the allocated packet we'll never send. */
- nx_packet_release(new_packet_ptr);
-
- /* Release the original packet. */
- nx_packet_release(packet_ptr);
-
- /* Error extracting packet buffer, return error status. */
- return;
- }
+ NX_ASSERT((status == NX_SUCCESS) && (bytes_copied > 0));
/* Update the new packet with the bytes copied. For chained packets, this will reflect the total
'datagram' length. */
@@ -5503,10 +5440,6 @@ ULONG probing_delay;
/* This will modify the timeout by up to +/- 1 second as recommended by RFC 2131, Section 4.1, Page 24. */
interface_record -> nx_dhcp_timeout = _nx_dhcp_add_randomize(interface_record -> nx_dhcp_timeout);
- /* Check if the timeout is zero. */
- if (interface_record -> nx_dhcp_timeout == 0)
- interface_record -> nx_dhcp_timeout = 1;
-
/* Update the state to Requesting state. */
interface_record -> nx_dhcp_state = NX_DHCP_STATE_REQUESTING;
}
@@ -5624,10 +5557,6 @@ ULONG probing_delay;
/* Use the minimum value, Wait one second to begain in INIT state and forms a DHCP Discovery message. */
interface_record -> nx_dhcp_timeout = NX_IP_PERIODIC_RATE;
interface_record -> nx_dhcp_rtr_interval = 0;
-
- /* Check if the timeout is less than 1 second. */
- if (interface_record -> nx_dhcp_timeout < NX_IP_PERIODIC_RATE)
- interface_record -> nx_dhcp_timeout = NX_IP_PERIODIC_RATE;
}
}
break;
@@ -5820,7 +5749,7 @@ ULONG probing_delay;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_timeout_process PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -5864,6 +5793,9 @@ ULONG probing_delay;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
VOID _nx_dhcp_timeout_process(NX_DHCP *dhcp_ptr)
@@ -5979,10 +5911,6 @@ NX_IP *ip_ptr;
/* This will modify the timeout by up to +/- 1 second as recommended by RFC 2131, Section 4.1, Page 24. */
interface_record -> nx_dhcp_timeout = _nx_dhcp_add_randomize(interface_record -> nx_dhcp_timeout);
- /* Check if the timeout is zero. */
- if (interface_record -> nx_dhcp_timeout == 0)
- interface_record -> nx_dhcp_timeout = 1;
-
break;
}
@@ -6006,10 +5934,6 @@ NX_IP *ip_ptr;
/* This will modify the timeout by up to +/- 1 second as recommended by RFC 2131, Section 4.1, Page 24. */
interface_record -> nx_dhcp_timeout = _nx_dhcp_add_randomize(interface_record -> nx_dhcp_timeout);
- /* Check if the timeout is zero. */
- if (interface_record -> nx_dhcp_timeout == 0)
- interface_record -> nx_dhcp_timeout = 1;
-
break;
}
@@ -6033,10 +5957,6 @@ NX_IP *ip_ptr;
/* This will modify the timeout by up to +/- 1 second as recommended by RFC 2131, Section 4.1, Page 24. */
interface_record -> nx_dhcp_timeout = _nx_dhcp_add_randomize(interface_record -> nx_dhcp_timeout);
- /* Check if the timeout is zero. */
- if (interface_record -> nx_dhcp_timeout == 0)
- interface_record -> nx_dhcp_timeout = 1;
-
break;
}
@@ -6604,7 +6524,7 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_send_request_internal PORTABLE C */
-/* 6.1.8 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -6664,6 +6584,10 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
/* adding additional request */
/* option in parameter request,*/
/* resulting in version 6.1.8 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), corrected*/
+/* the logic of adding server */
+/* identifier option, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
static UINT _nx_dhcp_send_request_internal(NX_DHCP *dhcp_ptr, NX_DHCP_INTERFACE_RECORD *interface_record, UINT dhcp_message_type)
@@ -6882,7 +6806,8 @@ UINT name_length;
/* Should add server ID if not renewing. */
if ((interface_record -> nx_dhcp_state != NX_DHCP_STATE_RENEWING) &&
(interface_record -> nx_dhcp_state != NX_DHCP_STATE_REBINDING) &&
- (interface_record -> nx_dhcp_server_ip != NX_BOOTP_BC_ADDRESS)
+ (interface_record -> nx_dhcp_server_ip != NX_BOOTP_BC_ADDRESS) &&
+ (interface_record -> nx_dhcp_server_ip != NX_BOOTP_NO_ADDRESS)
)
{
@@ -7067,7 +6992,7 @@ UINT name_length;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_client_send_with_zero_source_address PORTABLE C */
-/* 6.1.11 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -7108,6 +7033,12 @@ UINT name_length;
/* 04-25-2022 Yuxin Zhou Modified comment(s), and */
/* set the IP header pointer, */
/* resulting in version 6.1.11 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* improved internal logic, */
+/* and solve inconformity with */
+/* udp socket send and ip */
+/* header add, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
static UINT _nx_dhcp_client_send_with_zero_source_address(NX_DHCP *dhcp_ptr, UINT iface_index, NX_PACKET *packet_ptr)
@@ -7119,7 +7050,9 @@ NX_UDP_HEADER *udp_header_ptr;
NX_IPV4_HEADER *ip_header_ptr;
NX_INTERFACE *interface_ptr;
ULONG ip_src_addr, ip_dest_addr;
-UINT compute_checksum;
+#if defined(NX_DISABLE_UDP_TX_CHECKSUM) || defined(NX_DISABLE_IP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY)
+UINT compute_checksum = 1;
+#endif /* defined(NX_DISABLE_UDP_TX_CHECKSUM) || defined(NX_DISABLE_IP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) */
ULONG checksum;
ULONG val;
NX_IP_DRIVER driver_request;
@@ -7187,18 +7120,16 @@ NX_IP_DRIVER driver_request;
#ifdef NX_DISABLE_UDP_TX_CHECKSUM
compute_checksum = 0;
-#else /* NX_DISABLE_UDP_TX_CHECKSUM */
- compute_checksum = 1;
#endif /* NX_DISABLE_UDP_TX_CHECKSUM */
#ifdef NX_ENABLE_INTERFACE_CAPABILITY
if (interface_ptr -> nx_interface_capability_flag & NX_INTERFACE_CAPABILITY_UDP_TX_CHECKSUM)
compute_checksum = 0;
- else
- compute_checksum = 1;
#endif /* NX_ENABLE_INTERFACE_CAPABILITY */
+#if defined(NX_DISABLE_UDP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY)
if (compute_checksum)
+#endif /* defined(NX_DISABLE_UDP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) */
{
/* Yes, we need to compute the UDP checksum. */
checksum = _nx_ip_checksum_compute(packet_ptr,
@@ -7267,18 +7198,19 @@ NX_IP_DRIVER driver_request;
#ifdef NX_DISABLE_IP_TX_CHECKSUM
compute_checksum = 0;
-#else /* NX_DISABLE_IP_TX_CHECKSUM */
+#elif defined(NX_ENABLE_INTERFACE_CAPABILITY)
+ /* Re-initialize the value back to the default initial value (i.e. 1) */
compute_checksum = 1;
-#endif /* NX_DISABLE_IP_TX_CHECKSUM */
+#endif /* defined(NX_DISABLE_IP_TX_CHECKSUM) */
#ifdef NX_ENABLE_INTERFACE_CAPABILITY
if (packet_ptr -> nx_packet_address.nx_packet_interface_ptr -> nx_interface_capability_flag & NX_INTERFACE_CAPABILITY_IPV4_TX_CHECKSUM)
compute_checksum = 0;
- else
- compute_checksum = 1;
#endif /* NX_ENABLE_INTERFACE_CAPABILITY */
+#if defined(NX_DISABLE_IP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY)
if (compute_checksum)
+#endif /* defined(NX_DISABLE_IP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) */
{
checksum = _nx_ip_checksum_compute(packet_ptr, NX_IP_VERSION_V4, 20, NULL, NULL);
@@ -7690,7 +7622,7 @@ ULONG value;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_get_option_value PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -7730,6 +7662,9 @@ ULONG value;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
static UINT _nx_dhcp_get_option_value(UCHAR *bootp_message, UINT option, ULONG *value, UINT length)
@@ -7744,46 +7679,44 @@ UINT option_length;
option_message = &bootp_message[NX_BOOTP_OFFSET_OPTIONS];
option_length = length - NX_BOOTP_OFFSET_OPTIONS;
- /* Find the option. */
- if ((option != NX_DHCP_OPTION_PAD) && (option != NX_DHCP_OPTION_END))
- {
+ /* There is no need to check whether the option is PAD or END here since no caller will pass these 2 options
+ and for denfensive purpose, the function below could check them and guarantee appropriate behaviour */
+
+ /* Search the buffer for the option. */
+ data = _nx_dhcp_search_buffer(option_message, option, option_length);
- /* Search the buffer for the option. */
- data = _nx_dhcp_search_buffer(option_message, option, option_length);
+ /* Check to see if the option was found. */
+ if (data != NX_NULL)
+ {
- /* Check to see if the option was found. */
- if (data != NX_NULL)
+ /* Check for the proper size. */
+ if (*data > 4)
{
- /* Check for the proper size. */
- if (*data > 4)
+ /* Check for the gateway option. */
+ if (option == NX_DHCP_OPTION_GATEWAYS)
{
- /* Check for the gateway option. */
- if (option == NX_DHCP_OPTION_GATEWAYS)
- {
-
- /* Pickup the first gateway address. */
- *value = _nx_dhcp_get_data(data + 1, 4);
+ /* Pickup the first gateway address. */
+ *value = _nx_dhcp_get_data(data + 1, 4);
- /* For now, just disregard any additional gateway addresses. */
- return(NX_SUCCESS);
- }
- else
- {
-
- /* Invalid size, return error. */
- return(NX_SIZE_ERROR);
- }
+ /* For now, just disregard any additional gateway addresses. */
+ return(NX_SUCCESS);
}
else
{
- /* Get the actual value. */
- *value = _nx_dhcp_get_data(data + 1, *data);
- return(NX_SUCCESS);
+ /* Invalid size, return error. */
+ return(NX_SIZE_ERROR);
}
}
+ else
+ {
+
+ /* Get the actual value. */
+ *value = _nx_dhcp_get_data(data + 1, *data);
+ return(NX_SUCCESS);
+ }
}
/* Return an error if not found. */
@@ -7992,7 +7925,7 @@ static UINT _nx_dhcp_add_option_parameter_request(NX_DHCP *dhcp_ptr, UCHAR *boo
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_add_randomize PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -8026,6 +7959,9 @@ static UINT _nx_dhcp_add_option_parameter_request(NX_DHCP *dhcp_ptr, UCHAR *boo
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
static ULONG _nx_dhcp_add_randomize(ULONG timeout)
@@ -8048,7 +7984,7 @@ ULONG adjustment;
if (timeout > (NX_IP_PERIODIC_RATE - adjustment))
timeout -= (ULONG)(NX_IP_PERIODIC_RATE - adjustment);
else
- timeout = 0;
+ timeout = 1; /* Set 1 here since the minmum tick for timeout shall be larger than 0 */
}
else
{
@@ -8206,7 +8142,7 @@ static ULONG _nx_dhcp_update_renewal_timeout(ULONG timeout)
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_search_buffer PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -8246,6 +8182,9 @@ static ULONG _nx_dhcp_update_renewal_timeout(ULONG timeout)
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
static UCHAR *_nx_dhcp_search_buffer(UCHAR *option_message, UINT option, UINT length)
@@ -8262,9 +8201,14 @@ UINT size;
/* Search as long as there are valid options. */
while (i < length - 1)
{
+ /* Jump out when it reaches END option */
+ if (*data == NX_DHCP_OPTION_END)
+ {
+ break;
+ }
/* Simply skip any padding */
- if (*data == NX_DHCP_OPTION_PAD)
+ else if (*data == NX_DHCP_OPTION_PAD)
{
data++;
@@ -8372,7 +8316,7 @@ ULONG value = 0;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_store_data PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -8410,41 +8354,18 @@ ULONG value = 0;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
static VOID _nx_dhcp_store_data(UCHAR *data, UINT size, ULONG value)
{
-
- /* Make sure that data is left justified. */
- switch (size)
- {
-
- case 1:
-
- value <<= 24;
- break;
-
- case 2:
-
- value <<= 16;
- break;
-
- case 3:
-
- value <<= 8;
- break;
-
- default:
- break;
- }
-
/* Store the value. */
while (size-- > 0)
{
-
- *data = (UCHAR) ((value >> 24) & 0xff);
- data++;
- value <<= 8;
+ *(data + size) = (UCHAR)(value & 0xff);
+ value >>= 8;
}
}
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.c
index 26da0207..e88bf550 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.c
@@ -8315,7 +8315,7 @@ UCHAR original_state;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcpv6_send_request PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -8374,6 +8374,9 @@ UCHAR original_state;
/* verified memcpy use cases, */
/* fixed compiler warnings, */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), supported*/
+/* adding user options, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_dhcpv6_send_request(NX_DHCPV6 *dhcpv6_ptr)
@@ -8387,6 +8390,8 @@ UINT index;
NX_INTERFACE *interface_ptr;
NXD_IPV6_ADDRESS *ipv6_address;
ULONG available_payload;
+UCHAR *user_option_ptr;
+UINT user_option_length;
/* Initialize local variables. */
@@ -9020,12 +9025,37 @@ ULONG available_payload;
}
}
+ /* Add any user supplied options to the buffer. */
+ if (dhcpv6_ptr -> nx_dhcpv6_user_option_add)
+ {
+
+ /* Set the pointer for adding user option. */
+ user_option_ptr = buffer + index;
+
+ /* Calculate the available length for user options. */
+ user_option_length = (UINT)(packet_ptr -> nx_packet_data_end - user_option_ptr);
+
+ /* Add the specific DHCP option user wanted. */
+ if (dhcpv6_ptr -> nx_dhcpv6_user_option_add(dhcpv6_ptr, dhcpv6_ptr -> nx_dhcpv6_client_interface_index, dhcpv6_ptr -> nx_dhcpv6_message_hdr.nx_message_type, user_option_ptr, &user_option_length) == NX_TRUE)
+ {
+
+ /* Update the index to include the user options. */
+ index += user_option_length;
+ }
+ else
+ {
+
+ /* Invalid user options. Release the packet. */
+ nx_packet_release(packet_ptr);
+ return(NX_DHCPV6_UNKNOWN_OPTION);
+ }
+ }
+
/* Setup the packet pointers. */
packet_ptr -> nx_packet_length = index;
packet_ptr -> nx_packet_append_ptr = packet_ptr -> nx_packet_prepend_ptr + index;
-
/* Select Client Source address:
1. When a client sends a DHCP message to the All_DHCP_Relay_Agents_and_Servers address,
the client must use a link-local address assigned to the interface for which it
@@ -12082,6 +12112,124 @@ UINT _nx_dhcpv6_update_retransmit_info(NX_DHCPV6 *dhcpv6_ptr)
}
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _nxe_dhcpv6_user_option_add_callback_set PORTABLE C */
+/* 6.1.12 */
+/* AUTHOR */
+/* */
+/* Yuxin Zhou, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function performs error checking on the user option add */
+/* callback set service. */
+/* */
+/* INPUT */
+/* */
+/* dhcpv6_ptr Pointer to DHCPv6 instance */
+/* dhcpv6_user_option_add Pointer to application's */
+/* option add function */
+/* */
+/* OUTPUT */
+/* */
+/* status Completion status */
+/* */
+/* CALLS */
+/* */
+/* _nx_dhcpv6_user_option_add_callback_set Actual user option callback */
+/* set service */
+/* */
+/* CALLED BY */
+/* */
+/* Application Code */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 07-29-2022 Yuxin Zhou Initial Version 6.1.12 */
+/* */
+/**************************************************************************/
+UINT _nxe_dhcpv6_user_option_add_callback_set(NX_DHCPV6 *dhcpv6_ptr, UINT (*dhcpv6_user_option_add)(NX_DHCPV6 *dhcpv6_ptr, UINT interface_index, UINT message_type,
+ UCHAR *user_option_ptr, UINT *user_option_length))
+{
+
+UINT status;
+
+ /* Check for invalid input. */
+ if ((dhcpv6_ptr == NX_NULL) || (dhcpv6_user_option_add == NX_NULL))
+ {
+ return(NX_PTR_ERROR);
+ }
+
+ /* Call actual DHCPv6 user option callback set service. */
+ status = _nx_dhcpv6_user_option_add_callback_set(dhcpv6_ptr, dhcpv6_user_option_add);
+
+ /* Return status. */
+ return(status);
+}
+
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _nx_dhcpv6_user_option_add_callback_set PORTABLE C */
+/* 6.1.12 */
+/* AUTHOR */
+/* */
+/* Yuxin Zhou, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function sets the user option add callback. */
+/* */
+/* INPUT */
+/* */
+/* dhcpv6_ptr Pointer to DHCPv6 instance */
+/* dhcpv6_user_option_add Pointer to application's */
+/* option add function */
+/* */
+/* OUTPUT */
+/* */
+/* status Completion status */
+/* */
+/* CALLS */
+/* */
+/* None */
+/* */
+/* CALLED BY */
+/* */
+/* Application Code */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 07-29-2022 Yuxin Zhou Initial Version 6.1.12 */
+/* */
+/**************************************************************************/
+UINT _nx_dhcpv6_user_option_add_callback_set(NX_DHCPV6 *dhcpv6_ptr, UINT (*dhcpv6_user_option_add)(NX_DHCPV6 *dhcpv6_ptr, UINT interface_index, UINT message_type,
+ UCHAR *user_option_ptr, UINT *user_option_length))
+{
+
+ /* Obtain DHCPv6 Client protection mutex. */
+ tx_mutex_get(&(dhcpv6_ptr -> nx_dhcpv6_client_mutex), TX_WAIT_FOREVER);
+
+ /* Set the callback. */
+ dhcpv6_ptr -> nx_dhcpv6_user_option_add = dhcpv6_user_option_add;
+
+ /* Release the mutex. */
+ tx_mutex_put(&(dhcpv6_ptr -> nx_dhcpv6_client_mutex));
+
+ /* Return a successful status. */
+ return(NX_SUCCESS);
+}
+
+
#if !defined (NX_DISABLE_IPV6_DAD) && defined (NX_ENABLE_IPV6_ADDRESS_CHANGE_NOTIFY)
/**************************************************************************/
/* */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.h
index c9626666..56c1dda6 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.h
@@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* nxd_dhcpv6_client.h PORTABLE C */
-/* 6.1.9 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -49,6 +49,9 @@
/* 10-15-2021 Yuxin Zhou Modified comment(s), included */
/* necessary header file, */
/* resulting in version 6.1.9 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), supported*/
+/* adding user options, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@@ -757,6 +760,9 @@ typedef struct NX_DHCPV6_STRUCT
option the status is referring to e.g. IA Address. */
VOID (*nx_dhcpv6_server_error_handler)(struct NX_DHCPV6_STRUCT *dhcpv6_ptr, UINT op_code, UINT status_code, UINT message_type);
+ /* Define the callback function for adding specific DHCPv6 user option. */
+ UINT (*nx_dhcpv6_user_option_add)(struct NX_DHCPV6_STRUCT *dhcpv6_ptr, UINT interface_index, UINT message_type, UCHAR *user_option_ptr, UINT *user_option_length);
+
} NX_DHCPV6;
@@ -833,6 +839,7 @@ typedef struct NX_DHCPV6_CLIENT_RECORD_STRUCT
#define nx_dhcpv6_stop _nx_dhcpv6_stop
#define nx_dhcpv6_suspend _nx_dhcpv6_suspend
#define nx_dhcpv6_resume _nx_dhcpv6_resume
+#define nx_dhcpv6_user_option_add_callback_set _nx_dhcpv6_user_option_add_callback_set
#ifdef NX_DHCPV6_CLIENT_RESTORE_STATE
#define nx_dhcpv6_client_get_record _nx_dhcpv6_client_get_record
#define nx_dhcpv6_client_restore_record _nx_dhcpv6_client_restore_record
@@ -876,6 +883,7 @@ typedef struct NX_DHCPV6_CLIENT_RECORD_STRUCT
#define nx_dhcpv6_stop _nxe_dhcpv6_stop
#define nx_dhcpv6_suspend _nxe_dhcpv6_suspend
#define nx_dhcpv6_resume _nxe_dhcpv6_resume
+#define nx_dhcpv6_user_option_add_callback_set _nxe_dhcpv6_user_option_add_callback_set
#ifdef NX_DHCPV6_CLIENT_RESTORE_STATE
#define nx_dhcpv6_client_get_record _nxe_dhcpv6_client_get_record
#define nx_dhcpv6_client_restore_record _nxe_dhcpv6_client_restore_record
@@ -920,6 +928,7 @@ UINT nx_dhcpv6_start(NX_DHCPV6 *dhcpv6_ptr);
UINT nx_dhcpv6_stop(NX_DHCPV6 *dhcpv6_ptr);
UINT nx_dhcpv6_suspend(NX_DHCPV6 *dhcpv6_ptr);
UINT nx_dhcpv6_resume(NX_DHCPV6 *dhcpv6_ptr);
+UINT nx_dhcpv6_user_option_add_callback_set(NX_DHCPV6 *dhcpv6_ptr, UINT (*dhcpv6_user_option_add)(NX_DHCPV6 *dhcpv6_ptr, UINT interface_index, UINT message_type, UCHAR *user_option_ptr, UINT *user_option_length));
#ifdef NX_DHCPV6_CLIENT_RESTORE_STATE
UINT nx_dhcpv6_client_get_record(NX_DHCPV6 *dhcpv6_ptr, NX_DHCPV6_CLIENT_RECORD *client_record_ptr);
UINT nx_dhcpv6_client_restore_record(NX_DHCPV6 *dhcpv6_ptr, NX_DHCPV6_CLIENT_RECORD *client_record_ptr, ULONG time_elapsed);
@@ -999,7 +1008,9 @@ UINT _nx_dhcpv6_stop(NX_DHCPV6 *dhcpv6_ptr);
UINT _nxe_dhcpv6_suspend(NX_DHCPV6 *dhcpv6_ptr);
UINT _nx_dhcpv6_suspend(NX_DHCPV6 *dhcpv6_ptr);
UINT _nxe_dhcpv6_resume(NX_DHCPV6 *dhcpv6_ptr);
-UINT _nx_dhcpv6_resume(NX_DHCPV6 *dhcpv6_ptr);
+UINT _nx_dhcpv6_resume(NX_DHCPV6 *dhcpv6_ptr);
+UINT _nxe_dhcpv6_user_option_add_callback_set(NX_DHCPV6 *dhcpv6_ptr, UINT (*dhcpv6_user_option_add)(NX_DHCPV6 *dhcpv6_ptr, UINT interface_index, UINT message_type, UCHAR *user_option_ptr, UINT *user_option_length));
+UINT _nx_dhcpv6_user_option_add_callback_set(NX_DHCPV6 *dhcpv6_ptr, UINT (*dhcpv6_user_option_add)(NX_DHCPV6 *dhcpv6_ptr, UINT interface_index, UINT message_type, UCHAR *user_option_ptr, UINT *user_option_length));
#ifdef NX_DHCPV6_CLIENT_RESTORE_STATE
UINT _nxe_dhcpv6_client_get_record(NX_DHCPV6 *dhcpv6_ptr, NX_DHCPV6_CLIENT_RECORD *client_record_ptr);
UINT _nx_dhcpv6_client_get_record(NX_DHCPV6 *dhcpv6_ptr, NX_DHCPV6_CLIENT_RECORD *client_record_ptr);
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dns/nxd_dns.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dns/nxd_dns.c
index f96a9228..dc4cded7 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dns/nxd_dns.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dns/nxd_dns.c
@@ -192,7 +192,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_dns_create PORTABLE C */
-/* 6.1.4 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -233,6 +233,9 @@ UINT status;
/* 02-02-2021 Yuxin Zhou Modified comment(s), and */
/* randomized the source port, */
/* resulting in version 6.1.4 */
+/* 07-29-2022 Jidesh Veeramachaneni Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_dns_create(NX_DNS *dns_ptr, NX_IP *ip_ptr, UCHAR *domain_name)
@@ -261,22 +264,8 @@ UINT status;
#endif
/* Create the DNS UDP socket. */
- status = nx_udp_socket_create(ip_ptr, &(dns_ptr -> nx_dns_socket), "DNS Socket",
- NX_DNS_TYPE_OF_SERVICE, NX_DNS_FRAGMENT_OPTION, NX_DNS_TIME_TO_LIVE, NX_DNS_QUEUE_DEPTH);
-
- /* Check status of socket create. */
- if (status != NX_SUCCESS)
- {
-
-#ifndef NX_DNS_CLIENT_USER_CREATE_PACKET_POOL
-
- /* Delete the packet pool. */
- nx_packet_pool_delete(dns_ptr -> nx_dns_packet_pool_ptr);
-#endif
-
- /* Return the NetX error. */
- return(status);
- }
+ nx_udp_socket_create(ip_ptr, &(dns_ptr -> nx_dns_socket), "DNS Socket",
+ NX_DNS_TYPE_OF_SERVICE, NX_DNS_FRAGMENT_OPTION, NX_DNS_TIME_TO_LIVE, NX_DNS_QUEUE_DEPTH);
/* Create a DNS mutex for multi-thread access protection. */
status = tx_mutex_create(&dns_ptr -> nx_dns_mutex, "DNS Mutex", TX_NO_INHERIT);
@@ -539,7 +528,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_dns_delete PORTABLE C */
-/* 6.1.4 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -576,6 +565,10 @@ UINT status;
/* 02-02-2021 Yuxin Zhou Modified comment(s), and */
/* randomized the source port, */
/* resulting in version 6.1.4 */
+/* 07-29-2022 Jidesh Veeramachaneni Modified comment(s), */
+/* removed error checking for */
+/* nx_packet_pool_delete, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_dns_delete(NX_DNS *dns_ptr)
@@ -596,13 +589,8 @@ UINT status;
#ifndef NX_DNS_CLIENT_USER_CREATE_PACKET_POOL
/* Delete the DNS packet pool. */
- status = nx_packet_pool_delete(dns_ptr -> nx_dns_packet_pool_ptr);
+ nx_packet_pool_delete(dns_ptr -> nx_dns_packet_pool_ptr);
- if (status != NX_SUCCESS)
- {
- /* Return the packet pool delete error. */
- return status;
- }
#endif
/* Delete the DNS mutex. */
@@ -770,7 +758,7 @@ NXD_ADDRESS dns_server_address;
/* FUNCTION RELEASE */
/* */
/* _nxde_dns_server_add PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -804,6 +792,9 @@ NXD_ADDRESS dns_server_address;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Jidesh Veeramachaneni Modified comment(s) and */
+/* simplified some branches, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nxde_dns_server_add(NX_DNS *dns_ptr, NXD_ADDRESS *server_address)
@@ -826,14 +817,6 @@ UINT status;
return NX_DNS_PARAM_ERROR;
}
- /* Check for an invalid address type. */
- if ((server_address -> nxd_ip_version != NX_IP_VERSION_V4) &&
- (server_address -> nxd_ip_version != NX_IP_VERSION_V6))
- {
-
- return NX_DNS_INVALID_ADDRESS_TYPE;
- }
-
/* Check if the server address is unspecified (::). */
if (server_address -> nxd_ip_version == NX_IP_VERSION_V6)
{
@@ -869,6 +852,10 @@ UINT status;
return NX_DNS_INVALID_ADDRESS_TYPE;
#endif /* NX_DISABLE_IPV4 */
}
+ else
+ {
+ return NX_DNS_INVALID_ADDRESS_TYPE;
+ }
/* Check for appropriate caller. */
NX_THREADS_ONLY_CALLER_CHECKING
@@ -937,7 +924,7 @@ UINT _nxd_dns_server_add(NX_DNS *dns_ptr, NXD_ADDRESS *dns_server_address)
/* FUNCTION RELEASE */
/* */
/* _nx_dns_server_add_internal PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -972,6 +959,9 @@ UINT _nxd_dns_server_add(NX_DNS *dns_ptr, NXD_ADDRESS *dns_server_address)
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Jidesh Veeramachaneni Modified comment(s) and */
+/* simplified branches, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_dns_server_add_internal(NX_DNS *dns_ptr, NXD_ADDRESS *server_address)
@@ -1004,15 +994,17 @@ UINT i;
#ifndef NX_DISABLE_IPV4
/* Is there a match? */
- if ((server_address -> nxd_ip_version == NX_IP_VERSION_V4) &&
- (dns_ptr -> nx_dns_server_ip_array[i].nxd_ip_address.v4 == server_address -> nxd_ip_address.v4))
+ if (server_address -> nxd_ip_version == NX_IP_VERSION_V4)
{
+ if (dns_ptr -> nx_dns_server_ip_array[i].nxd_ip_address.v4 == server_address -> nxd_ip_address.v4)
+ {
- /* Error, release the mutex and return. */
- tx_mutex_put(&(dns_ptr -> nx_dns_mutex));
+ /* Error, release the mutex and return. */
+ tx_mutex_put(&(dns_ptr -> nx_dns_mutex));
- /* Yes, no need to add to the table, just return the 'error' status. */
- return NX_DNS_DUPLICATE_ENTRY;
+ /* Yes, no need to add to the table, just return the 'error' status. */
+ return NX_DNS_DUPLICATE_ENTRY;
+ }
}
#else
/* Error, release the mutex and return. */
@@ -1028,16 +1020,18 @@ UINT i;
#ifdef FEATURE_NX_IPV6
/* Is there a match? */
- if ((server_address -> nxd_ip_version == NX_IP_VERSION_V6) &&
- CHECK_IPV6_ADDRESSES_SAME(&dns_ptr -> nx_dns_server_ip_array[i].nxd_ip_address.v6[0],
- &(server_address -> nxd_ip_address.v6[0])))
+ if (server_address -> nxd_ip_version == NX_IP_VERSION_V6)
{
+ if (CHECK_IPV6_ADDRESSES_SAME(&dns_ptr -> nx_dns_server_ip_array[i].nxd_ip_address.v6[0],
+ &(server_address -> nxd_ip_address.v6[0])))
+ {
- /* Error, release the mutex and return. */
- tx_mutex_put(&(dns_ptr -> nx_dns_mutex));
+ /* Error, release the mutex and return. */
+ tx_mutex_put(&(dns_ptr -> nx_dns_mutex));
- /* Yes, no need to add to the table, just return the 'error' status. */
- return NX_DNS_DUPLICATE_ENTRY;
+ /* Yes, no need to add to the table, just return the 'error' status. */
+ return NX_DNS_DUPLICATE_ENTRY;
+ }
}
#else
/* Error, release the mutex and return. */
@@ -1244,7 +1238,7 @@ NXD_ADDRESS dns_server_address;
/* FUNCTION RELEASE */
/* */
/* _nxde_dns_server_remove PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -1279,6 +1273,10 @@ NXD_ADDRESS dns_server_address;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Jidesh Veeramachaneni Modified comment(s) and */
+/* simplified check for */
+/* invalid address types, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nxde_dns_server_remove(NX_DNS *dns_ptr, NXD_ADDRESS *server_address)
@@ -1292,14 +1290,6 @@ UINT status;
return(NX_PTR_ERROR);
}
- /* Check for an invalid address type. */
- if ((server_address -> nxd_ip_version != NX_IP_VERSION_V4) &&
- (server_address -> nxd_ip_version != NX_IP_VERSION_V6))
- {
-
- return NX_DNS_INVALID_ADDRESS_TYPE;
- }
-
/* Check if the server address is unspecified (::). */
if (server_address -> nxd_ip_version == NX_IP_VERSION_V6)
{
@@ -1335,6 +1325,10 @@ UINT status;
return NX_DNS_INVALID_ADDRESS_TYPE;
#endif /* NX_DISABLE_IPV4 */
}
+ else
+ {
+ return NX_DNS_INVALID_ADDRESS_TYPE;
+ }
/* Check for appropriate caller. */
NX_THREADS_ONLY_CALLER_CHECKING
@@ -1406,7 +1400,7 @@ UINT _nxd_dns_server_remove(NX_DNS *dns_ptr, NXD_ADDRESS *server_address)
/* FUNCTION RELEASE */
/* */
/* _nx_dns_server_remove_internal PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -1444,6 +1438,9 @@ UINT _nxd_dns_server_remove(NX_DNS *dns_ptr, NXD_ADDRESS *server_address)
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Jidesh Veeramachaneni Modified comment(s) and */
+/* removed null IP checks, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
static UINT _nx_dns_server_remove_internal(NX_DNS *dns_ptr, NXD_ADDRESS *server_address)
@@ -1488,50 +1485,24 @@ UINT found_match;
}
#else
{
- /* Check for a null address. */
- if (!CHECK_UNSPECIFIED_ADDRESS(&DNSserver_array[i].nxd_ip_address.v6[0]))
+ /* Determine if this entry matches the specified DNS server. */
+ if (CHECK_IPV6_ADDRESSES_SAME(&DNSserver_array[i].nxd_ip_address.v6[0], &(server_address -> nxd_ip_address.v6[0])))
{
- /* No null; Determine if this entry matches the specified DNS server. */
- if (CHECK_IPV6_ADDRESSES_SAME(&DNSserver_array[i].nxd_ip_address.v6[0], &(server_address -> nxd_ip_address.v6[0])))
- {
-
- found_match = NX_TRUE;
- break;
- }
- }
- /* Check for a null address. */
- else
- {
-
- /* Error, release the mutex and return. */
- tx_mutex_put(&(dns_ptr -> nx_dns_mutex));
- return NX_DNS_BAD_ADDRESS_ERROR;
+ found_match = NX_TRUE;
+ break;
}
}
#endif
else if (DNSserver_array[i].nxd_ip_version == NX_IP_VERSION_V4)
#ifndef NX_DISABLE_IPV4
{
-
- /* Check for a null address. */
- if (DNSserver_array[i].nxd_ip_address.v4 != IP_ADDRESS(0, 0, 0, 0))
+ /* Determine if this entry matches the specified DNS server. */
+ if (DNSserver_array[i].nxd_ip_address.v4 == server_address -> nxd_ip_address.v4)
{
-
- /* Determine if this entry matches the specified DNS server. */
- if (DNSserver_array[i].nxd_ip_address.v4 == server_address -> nxd_ip_address.v4)
- {
- found_match = NX_TRUE;
- break;
- }
- }
- else
- {
-
- /* Error, release the mutex and return. */
- tx_mutex_put(&(dns_ptr -> nx_dns_mutex));
- return NX_DNS_INVALID_ADDRESS_TYPE;
+ found_match = NX_TRUE;
+ break;
}
}
#else
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.c
index d8b4bbad..c015ebec 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.c
@@ -41,10 +41,9 @@
#endif
#ifdef NX_HTTP_DIGEST_ENABLE
-/* Define the default nonce, used only for MD5 authentication. For security reasons, this ASCII value should
- change over time. */
-CHAR _nx_http_server_nonce[] = "a4b8c8d7e0f6a7b2c3d2e4f5a4b7c5d2e7f";
+/* Use for mapping random nonces to printable characters. */
+static CHAR _nx_http_server_base64_array[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
#endif
/* Define date strings. */
@@ -1539,7 +1538,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_http_server_delete PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -1561,9 +1560,8 @@ UINT status;
/* CALLS */
/* */
/* nx_tcp_socket_delete Delete the HTTP server socket */
-/* nx_tcp_socket_disconnect Disconnect HTTP server socket */
-/* nx_tcp_socket_unaccept Unaccept HTTP server connect */
-/* nx_tcp_socket_unlisten Unlisten on the HTTP port */
+/* _nx_http_server_disconnect Disconnect HTTP server socket */
+/* nx_tcp_server_socket_unlisten Unlisten on the HTTP port */
/* tx_thread_delete Delete the HTTP server thread */
/* tx_thread_suspend Suspend the HTTP server thread*/
/* tx_thread_terminate Terminate the HTTP server */
@@ -1580,6 +1578,9 @@ UINT status;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* supported random nonce, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_http_server_delete(NX_HTTP_SERVER *http_server_ptr)
@@ -1590,10 +1591,7 @@ UINT _nx_http_server_delete(NX_HTTP_SERVER *http_server_ptr)
http_server_ptr -> nx_http_server_id = 0;
/* Disconnect the TCP socket. */
- nx_tcp_socket_disconnect(&(http_server_ptr -> nx_http_server_socket), NX_HTTP_SERVER_TIMEOUT_DISCONNECT);
-
- /* Unaccept any remaining connection on the TCP socket. */
- nx_tcp_server_socket_unaccept(&(http_server_ptr -> nx_http_server_socket));
+ _nx_http_server_disconnect(http_server_ptr, NX_HTTP_SERVER_TIMEOUT_DISCONNECT);
/* Delete the TCP socket. */
nx_tcp_socket_delete(&(http_server_ptr -> nx_http_server_socket));
@@ -2247,7 +2245,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_http_server_stop PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -2268,6 +2266,8 @@ UINT status;
/* */
/* CALLS */
/* */
+/* _nx_http_server_disconnect Disconnect HTTP server socket */
+/* nx_tcp_server_socket_unlisten Unlisten on the HTTP port */
/* tx_thread_suspend Suspend the HTTP server thread*/
/* */
/* CALLED BY */
@@ -2281,20 +2281,91 @@ UINT status;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* supported random nonce, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_http_server_stop(NX_HTTP_SERVER *http_server_ptr)
{
/* Disconnect the TCP socket. */
- nx_tcp_socket_disconnect(&(http_server_ptr -> nx_http_server_socket), NX_NO_WAIT);
-
- /* Unaccept any remaining connection on the TCP socket. */
- nx_tcp_server_socket_unaccept(&(http_server_ptr -> nx_http_server_socket));
+ _nx_http_server_disconnect(http_server_ptr, NX_NO_WAIT);
/* Unlisten on the HTTP server port. */
nx_tcp_server_socket_unlisten(http_server_ptr -> nx_http_server_ip_ptr, NX_HTTP_SERVER_PORT);
+ /* Suspend the HTTP server thread. */
+ tx_thread_suspend(&(http_server_ptr -> nx_http_server_thread));
+
+ /* Return successful completion. */
+ return(NX_SUCCESS);
+}
+
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _nx_http_server_disconnect PORTABLE C */
+/* 6.2.0 */
+/* AUTHOR */
+/* */
+/* Yuxin Zhou, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function disconnects the HTTP server socket. */
+/* */
+/* */
+/* INPUT */
+/* */
+/* http_server_ptr Pointer to HTTP server */
+/* wait_option Wait option */
+/* */
+/* OUTPUT */
+/* */
+/* status Completion status */
+/* */
+/* CALLS */
+/* */
+/* nx_tcp_socket_disconnect Disconnect HTTP server socket */
+/* nx_tcp_socket_unaccept Unaccept HTTP server connect */
+/* */
+/* CALLED BY */
+/* */
+/* Application Code */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 10-31-2022 Yuxin Zhou Initial Version 6.2.0 */
+/* */
+/**************************************************************************/
+UINT _nx_http_server_disconnect(NX_HTTP_SERVER *http_server_ptr, UINT wait_option)
+{
+
+#ifdef NX_HTTP_DIGEST_ENABLE
+UINT i;
+
+ /* Once the nonce has been accepted, set the state as invalid. */
+ for (i = 0; i < NX_HTTP_SERVER_NONCE_MAX; i++)
+ {
+ if (http_server_ptr -> nx_http_server_nonces[i].nonce_state == NX_HTTP_SERVER_NONCE_ACCEPTED)
+ {
+ http_server_ptr -> nx_http_server_nonces[i].nonce_state = NX_HTTP_SERVER_NONCE_INVALID;
+ break;
+ }
+ }
+#endif /* NX_HTTP_DIGEST_ENABLE */
+
+ /* Disconnect the TCP socket. */
+ nx_tcp_socket_disconnect(&(http_server_ptr -> nx_http_server_socket), wait_option);
+
+ /* Unaccept any remaining connection on the TCP socket. */
+ nx_tcp_server_socket_unaccept(&(http_server_ptr -> nx_http_server_socket));
+
/* Return successful completion. */
return(NX_SUCCESS);
}
@@ -2829,7 +2900,7 @@ NX_HTTP_SERVER *server_ptr;
/* FUNCTION RELEASE */
/* */
/* _nx_http_server_thread_entry PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -2857,10 +2928,9 @@ NX_HTTP_SERVER *server_ptr;
/* _nx_http_server_response_send Send HTTP Server response */
/* nx_packet_release Release request packet */
/* nx_tcp_server_socket_accept Accept HTTP client connect */
-/* nx_tcp_socket_disconnect Disconnect from HTTP client */
+/* _nx_http_server_disconnect Disconnect HTTP server socket */
/* nx_tcp_server_socket_relisten Relisten for another HTTP */
/* client connection */
-/* nx_tcp_server_socket_unaccept Unaccept HTTP client connect */
/* tx_thread_preemption_change Disable/restore preemption */
/* tx_thread_suspend Self suspend HTTP thread */
/* */
@@ -2875,6 +2945,9 @@ NX_HTTP_SERVER *server_ptr;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* supported random nonce, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID _nx_http_server_thread_entry(ULONG http_server)
@@ -2960,10 +3033,7 @@ UINT loop_endlessly = NX_TRUE;
}
/* Disconnect from the current connection. */
- nx_tcp_socket_disconnect(&(server_ptr -> nx_http_server_socket), NX_HTTP_SERVER_TIMEOUT_DISCONNECT);
-
- /* Unaccept the connection. */
- nx_tcp_server_socket_unaccept(&(server_ptr -> nx_http_server_socket));
+ _nx_http_server_disconnect(server_ptr, NX_HTTP_SERVER_TIMEOUT_DISCONNECT);
/* Relisten on the HTTP Server port. */
nx_tcp_server_socket_relisten(server_ptr -> nx_http_server_ip_ptr, NX_HTTP_SERVER_PORT,
@@ -3087,10 +3157,7 @@ UINT loop_endlessly = NX_TRUE;
nx_packet_release(packet_ptr);
/* Disconnect from the current connection. */
- nx_tcp_socket_disconnect(&(server_ptr -> nx_http_server_socket), NX_HTTP_SERVER_TIMEOUT_DISCONNECT);
-
- /* Unaccept the connection. */
- nx_tcp_server_socket_unaccept(&(server_ptr -> nx_http_server_socket));
+ _nx_http_server_disconnect(server_ptr, NX_HTTP_SERVER_TIMEOUT_DISCONNECT);
/* Relisten on the HTTP Server port. */
nx_tcp_server_socket_relisten(server_ptr -> nx_http_server_ip_ptr, NX_HTTP_SERVER_PORT,
@@ -4701,7 +4768,7 @@ NX_PACKET *packet_ptr;
/* FUNCTION RELEASE */
/* */
/* _nx_http_server_basic_authenticate PORTABLE C */
-/* 6.1.6 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -4754,6 +4821,10 @@ NX_PACKET *packet_ptr;
/* improved the logic of */
/* parsing base64, */
/* resulting in version 6.1.6 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), fixed */
+/* the issue of processing */
+/* empty password, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_http_server_basic_authenticate(NX_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *name_ptr, CHAR *password_ptr, CHAR *realm_ptr, UINT realm_length, UINT *auth_request_present)
@@ -4835,7 +4906,9 @@ UINT authorization_decoded_size;
}
/* Determine if we have a match. */
- if (match && (i == authorization_decoded_size) && (authorization_decoded[i] == (CHAR) NX_NULL))
+ if (match && (i == authorization_decoded_size) &&
+ (authorization_decoded[i] == (CHAR) NX_NULL) &&
+ (password_ptr[j] == (CHAR) NX_NULL))
{
/* Yes, we have successful authorization!! */
@@ -5707,12 +5780,106 @@ UINT temp_name_length;
}
#ifdef NX_HTTP_DIGEST_ENABLE
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _nx_http_server_nonce_allocate PORTABLE C */
+/* 6.2.0 */
+/* AUTHOR */
+/* */
+/* Yuxin Zhou, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function allocate a new nonce for digest authentication. */
+/* */
+/* INPUT */
+/* */
+/* server_ptr HTTP Server pointer */
+/* nonce_ptr Allocated nonce pointer */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* tx_time_get Get system time */
+/* */
+/* CALLED BY */
+/* */
+/* _nx_http_server_digest_authenticate Digest authentication */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 10-31-2022 Yuxin Zhou Initial Version 6.2.0 */
+/* */
+/**************************************************************************/
+UINT _nx_http_server_nonce_allocate(NX_HTTP_SERVER *server_ptr, NX_HTTP_SERVER_NONCE **nonce_ptr)
+{
+UINT i;
+UCHAR random_value;
+NX_HTTP_SERVER_NONCE *nonces_list = server_ptr -> nx_http_server_nonces;
+
+
+ /* Search if there is free entry for new nonce. */
+ for (i = 0; i < NX_HTTP_SERVER_NONCE_MAX; i++)
+ {
+ if (nonces_list[i].nonce_state == NX_HTTP_SERVER_NONCE_INVALID)
+ {
+ *nonce_ptr = &(nonces_list[i]);
+ break;
+ }
+ }
+
+ if (i == NX_HTTP_SERVER_NONCE_MAX)
+ {
+
+ /* If no free entry, check the timeout of allocated nonces. */
+ for (i = 0; i < NX_HTTP_SERVER_NONCE_MAX; i++)
+ {
+ if (nonces_list[i].nonce_state == NX_HTTP_SERVER_NONCE_VALID)
+ {
+ if (tx_time_get() > nonces_list[i].nonce_timestamp + NX_HTTP_SERVER_NONCE_TIMEOUT)
+ {
+
+ /* If this nonce is timed out, free up this entry for new nonce. */
+ *nonce_ptr = &(nonces_list[i]);
+ break;
+ }
+ }
+ }
+
+ /* If no entry can be allocated, return error. */
+ if (i == NX_HTTP_SERVER_NONCE_MAX)
+ {
+ return(NX_NOT_FOUND);
+ }
+ }
+
+ /* Generate new nonce for digest authentication. */
+ for (i = 0; i < NX_HTTP_SERVER_NONCE_SIZE; i++)
+ {
+ random_value = (UCHAR)NX_RAND() % (sizeof(_nx_http_server_base64_array) - 1);
+ (*nonce_ptr) -> nonce_buffer[i] = (UCHAR)_nx_http_server_base64_array[random_value];
+ }
+
+ /* Reset the timestamp and state for the new nonce. */
+ (*nonce_ptr) -> nonce_timestamp = tx_time_get();
+ (*nonce_ptr) -> nonce_state = NX_HTTP_SERVER_NONCE_VALID;
+
+ return(NX_SUCCESS);
+}
+
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nx_http_server_digest_authenticate PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -5763,6 +5930,9 @@ UINT temp_name_length;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* supported random nonce, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_http_server_digest_authenticate(NX_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *name_ptr, UINT name_length, CHAR *password_ptr, UINT password_length, CHAR *realm_ptr, UINT realm_length, UINT *auth_request_present)
@@ -5779,6 +5949,8 @@ UINT status, status1, callback_status;
CHAR crlf[2] = {13,10};
CHAR authorization_nc[NX_HTTP_MAX_RESOURCE + 1];
CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1];
+NX_HTTP_SERVER_NONCE *nonce_ptr = NX_NULL;
+
/* Default to no authentication request detected. */
*auth_request_present = NX_FALSE;
@@ -5787,7 +5959,7 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1];
status = NX_HTTP_DIGEST_AUTHENTICATE;
/* Is the authorization request present? */
- if (_nx_http_server_retrieve_digest_authorization(packet_ptr, authorization_response, authorization_uri, authorization_nc, authorization_cnonce))
+ if (_nx_http_server_retrieve_digest_authorization(server_ptr, packet_ptr, authorization_response, authorization_uri, authorization_nc, authorization_cnonce, &nonce_ptr))
{
/* Yes, an authorization request is present. */
@@ -5822,7 +5994,7 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1];
/* Calculate what the MD5 should be. */
- _nx_http_server_digest_response_calculate(server_ptr, name_ptr, name_length, realm_ptr, realm_length, password_ptr, password_length, _nx_http_server_nonce, method, authorization_uri, authorization_nc, authorization_cnonce, calculated_response);
+ _nx_http_server_digest_response_calculate(server_ptr, name_ptr, name_length, realm_ptr, realm_length, password_ptr, password_length, (CHAR *)(nonce_ptr -> nonce_buffer), method, authorization_uri, authorization_nc, authorization_cnonce, calculated_response);
/* Determine if the calculated response is the same as the received response. */
i = 0;
@@ -5840,6 +6012,17 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1];
/* Otherwise, look at next character. */
i++;
}
+
+ /* If the response is authenticated, mark the nonce as accepted. */
+ if (status == NX_SUCCESS)
+ {
+ nonce_ptr -> nonce_state = NX_HTTP_SERVER_NONCE_ACCEPTED;
+ }
+ else
+ {
+ nonce_ptr -> nonce_state = NX_HTTP_SERVER_NONCE_INVALID;
+ }
+
/* If digest authenticate callback function returns non-success value, the request is
considered unauthenticated. */
if(callback_status != NX_SUCCESS)
@@ -5850,6 +6033,24 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1];
if (status == NX_HTTP_DIGEST_AUTHENTICATE)
{
+ /* Allocate a new nonce for digest authentication. */
+ status1 = _nx_http_server_nonce_allocate(server_ptr, &nonce_ptr);
+
+ /* Determine if an error occurred in the packet allocation. */
+ if (status1)
+ {
+
+ /* Send response back to HTTP Client. */
+ _nx_http_server_response_send(server_ptr, NX_HTTP_STATUS_INTERNAL_ERROR, sizeof(NX_HTTP_STATUS_INTERNAL_ERROR) - 1,
+ "NetX HTTP Server Internal Error", sizeof("NetX HTTP Server Internal Error") - 1, NX_NULL, 0);
+
+ /* Indicate an allocation error occurred. */
+ server_ptr -> nx_http_server_allocation_errors++;
+
+ /* Return the internal NetX error. */
+ return(status1);
+ }
+
/* We need authorization so build the HTTP 401 Unauthorized message to send to the server. */
/* Allocate a packet for sending the response back. */
@@ -5926,7 +6127,7 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1];
server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
/* Place the nonce string into the buffer. */
- nx_packet_data_append(packet_ptr, _nx_http_server_nonce, sizeof(_nx_http_server_nonce) - 1,
+ nx_packet_data_append(packet_ptr, nonce_ptr -> nonce_buffer, NX_HTTP_SERVER_NONCE_SIZE,
server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
/* Insert the double quote. */
@@ -5941,6 +6142,14 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1];
nx_packet_data_append(packet_ptr, crlf, 2,
server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
+ /* Set Content-Length as 0. */
+ nx_packet_data_append(packet_ptr, "Content-Length: 0", 17,
+ server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
+
+ /* Place the into the buffer. */
+ nx_packet_data_append(packet_ptr, crlf, 2,
+ server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
+
/* Place another into the buffer to signal end of FULL HTTP response. */
nx_packet_data_append(packet_ptr, crlf, 2,
server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
@@ -5970,7 +6179,7 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1];
/* FUNCTION RELEASE */
/* */
/* _nx_http_server_digest_response_calculate PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -6016,6 +6225,9 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1];
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* supported random nonce, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID _nx_http_server_digest_response_calculate(NX_HTTP_SERVER *server_ptr, CHAR *username, UINT username_length, CHAR *realm, UINT realm_length, CHAR *password, UINT password_length, CHAR *nonce, CHAR *method, CHAR *uri, CHAR *nc, CHAR *cnonce, CHAR *result)
@@ -6026,14 +6238,12 @@ CHAR ha1_string[NX_HTTP_MAX_ASCII_MD5 + 1];
CHAR ha2_string[NX_HTTP_MAX_ASCII_MD5 + 1];
UINT method_length;
UINT uri_length;
-UINT nonce_length;
UINT nc_length;
UINT cnonce_length;
/* Check string length. */
if (_nx_utility_string_length_check(method, &method_length, 7) ||
_nx_utility_string_length_check(uri, &uri_length, NX_HTTP_MAX_RESOURCE) ||
- _nx_utility_string_length_check(nonce, &nonce_length, sizeof(_nx_http_server_nonce) - 1) ||
_nx_utility_string_length_check(nc, &nc_length, NX_HTTP_MAX_RESOURCE) ||
_nx_utility_string_length_check(cnonce, &cnonce_length, NX_HTTP_MAX_RESOURCE))
{
@@ -6067,7 +6277,7 @@ UINT cnonce_length;
_nx_md5_initialize(&(server_ptr -> nx_http_server_md5data));
_nx_md5_update(&(server_ptr -> nx_http_server_md5data), (unsigned char *) ha1_string, sizeof(ha1_string) - 1);
_nx_md5_update(&(server_ptr -> nx_http_server_md5data), (unsigned char *) ":", 1);
- _nx_md5_update(&(server_ptr -> nx_http_server_md5data), (unsigned char *) nonce, nonce_length);
+ _nx_md5_update(&(server_ptr -> nx_http_server_md5data), (unsigned char *) nonce, NX_HTTP_SERVER_NONCE_SIZE);
/* Start of Internet Explorer bug work-around. */
_nx_md5_update(&(server_ptr -> nx_http_server_md5data), (unsigned char *) ":", 1);
@@ -6092,7 +6302,7 @@ UINT cnonce_length;
/* FUNCTION RELEASE */
/* */
/* _nx_http_server_retrieve_digest_authorization PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -6104,11 +6314,13 @@ UINT cnonce_length;
/* */
/* INPUT */
/* */
+/* server_ptr HTTP Server pointer */
/* packet_ptr Request packet pointer */
/* response Digest response pointer */
/* uri URI from response pointer */
/* nc Nonce count string */
/* cnonce Client nonce string */
+/* nonce_ptr Server nonce pointer */
/* */
/* OUTPUT */
/* */
@@ -6131,15 +6343,20 @@ UINT cnonce_length;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* supported random nonce, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
-UINT _nx_http_server_retrieve_digest_authorization(NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce)
+UINT _nx_http_server_retrieve_digest_authorization(NX_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce, NX_HTTP_SERVER_NONCE **nonce_ptr)
{
UINT length;
UINT found;
CHAR *buffer_ptr;
CHAR *saved_buffer_ptr;
+UCHAR *nonce_buffer;
+UINT i;
/* Set the found flag to false. */
@@ -6259,6 +6476,86 @@ CHAR *saved_buffer_ptr;
/* Save current buffer pointer, so each parameter search always starts from here. */
saved_buffer_ptr = buffer_ptr;
+ while (((buffer_ptr + 6) < (CHAR *) packet_ptr -> nx_packet_append_ptr) && (*buffer_ptr != (CHAR) 0))
+ {
+
+ /* Check for the uri token. */
+ if (((*(buffer_ptr) == 'n') || (*(buffer_ptr) == 'N')) &&
+ ((*(buffer_ptr+1) == 'o') || (*(buffer_ptr+1) == 'O')) &&
+ ((*(buffer_ptr+2) == 'n') || (*(buffer_ptr+2) == 'N')) &&
+ ((*(buffer_ptr+3) == 'c') || (*(buffer_ptr+3) == 'C')) &&
+ ((*(buffer_ptr+4) == 'e') || (*(buffer_ptr+4) == 'E')) &&
+ (*(buffer_ptr+5) == '='))
+ {
+
+ /* Move the pointer up to the actual nonce string. */
+ buffer_ptr = buffer_ptr + 6;
+ found = NX_TRUE;
+
+ break;
+ }
+
+ /* Move the pointer up to the next character. */
+ buffer_ptr++;
+ }
+
+ /* Check if nonce is found. */
+ if (!found)
+ {
+ return(0);
+ }
+
+ /* Now remove any extra blanks and quotes. */
+ while ((buffer_ptr < (CHAR *) packet_ptr -> nx_packet_append_ptr) && ((*buffer_ptr == ' ') || (*buffer_ptr == (CHAR) 0x22)))
+ {
+
+ /* Move the pointer up one character. */
+ buffer_ptr++;
+ }
+
+ /* Now pickup the nonce string. */
+ length = 0;
+ nonce_buffer = (UCHAR *)buffer_ptr;
+ while ((buffer_ptr < (CHAR *) packet_ptr -> nx_packet_append_ptr) && (*buffer_ptr != (CHAR) 0) && (*buffer_ptr != ' ') && (*buffer_ptr != (CHAR) 13))
+ {
+
+ /* Determine if the ending quote is present. */
+ if (*buffer_ptr == (CHAR) 0x22)
+ {
+ break;
+ }
+
+ /* Increase the length. */
+ length++;
+ buffer_ptr++;
+ }
+
+ /* Check the nonce size. */
+ if (length != NX_HTTP_SERVER_NONCE_SIZE)
+ {
+ return(0);
+ }
+
+ /* Check if the nonce is valid. */
+ for (i = 0; i < NX_HTTP_SERVER_NONCE_MAX; i++)
+ {
+ if ((server_ptr -> nx_http_server_nonces[i].nonce_state != NX_HTTP_SERVER_NONCE_INVALID) &&
+ (memcmp(server_ptr -> nx_http_server_nonces[i].nonce_buffer, nonce_buffer, NX_HTTP_SERVER_NONCE_SIZE) == 0)) /* Use case of memcmp is verified. */
+ {
+ *nonce_ptr = &(server_ptr -> nx_http_server_nonces[i]);
+ break;
+ }
+ }
+
+ /* If the nonca is invalid, just return. */
+ if (i == NX_HTTP_SERVER_NONCE_MAX)
+ {
+ return(0);
+ }
+
+ /* Get saved buffer pointer. */
+ buffer_ptr = saved_buffer_ptr;
+
/* Now look for the nc in the digest response. */
while (((buffer_ptr+3) < (CHAR *) packet_ptr -> nx_packet_append_ptr) && (*buffer_ptr != (CHAR) 0))
{
@@ -6318,9 +6615,9 @@ CHAR *saved_buffer_ptr;
if (((*buffer_ptr == 'c') || (*buffer_ptr == 'C')) &&
((*(buffer_ptr+1) == 'n') || (*(buffer_ptr+1) == 'N')) &&
((*(buffer_ptr+2) == 'o') || (*(buffer_ptr+2) == 'O')) &&
- ((*(buffer_ptr+3) == 'n') || (*(buffer_ptr+2) == 'N')) &&
- ((*(buffer_ptr+4) == 'c') || (*(buffer_ptr+2) == 'C')) &&
- ((*(buffer_ptr+5) == 'e') || (*(buffer_ptr+2) == 'E')) &&
+ ((*(buffer_ptr+3) == 'n') || (*(buffer_ptr+3) == 'N')) &&
+ ((*(buffer_ptr+4) == 'c') || (*(buffer_ptr+4) == 'C')) &&
+ ((*(buffer_ptr+5) == 'e') || (*(buffer_ptr+5) == 'E')) &&
(*(buffer_ptr+6) == '='))
{
@@ -6425,11 +6722,11 @@ CHAR *saved_buffer_ptr;
if (((*buffer_ptr == 'r') || (*buffer_ptr == 'R')) &&
((*(buffer_ptr+1) == 'e') || (*(buffer_ptr+1) == 'E')) &&
((*(buffer_ptr+2) == 's') || (*(buffer_ptr+2) == 'S')) &&
- ((*(buffer_ptr+3) == 'p') || (*(buffer_ptr+2) == 'P')) &&
- ((*(buffer_ptr+4) == 'o') || (*(buffer_ptr+2) == 'O')) &&
- ((*(buffer_ptr+5) == 'n') || (*(buffer_ptr+2) == 'N')) &&
- ((*(buffer_ptr+6) == 's') || (*(buffer_ptr+2) == 'S')) &&
- ((*(buffer_ptr+7) == 'e') || (*(buffer_ptr+2) == 'E')) &&
+ ((*(buffer_ptr+3) == 'p') || (*(buffer_ptr+3) == 'P')) &&
+ ((*(buffer_ptr+4) == 'o') || (*(buffer_ptr+4) == 'O')) &&
+ ((*(buffer_ptr+5) == 'n') || (*(buffer_ptr+5) == 'N')) &&
+ ((*(buffer_ptr+6) == 's') || (*(buffer_ptr+6) == 'S')) &&
+ ((*(buffer_ptr+7) == 'e') || (*(buffer_ptr+7) == 'E')) &&
(*(buffer_ptr+8) == '='))
{
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.h
index ffa237b6..ffe9b0e9 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.h
@@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* nxd_http_server.h PORTABLE C */
-/* 6.1.8 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -53,6 +53,10 @@
/* improved the logic of */
/* converting number to string,*/
/* resulting in version 6.1.8 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* supported random nonce, */
+/* resulting in version 6.2.0 */
+/* */
/* */
/**************************************************************************/
@@ -180,6 +184,24 @@ extern "C" {
#define NX_HTTP_SERVER_RETRY_SHIFT 1 /* Every retry is twice as long */
#endif
+#ifndef NX_HTTP_SERVER_NONCE_SIZE
+#define NX_HTTP_SERVER_NONCE_SIZE 32 /* The size of nonce for digest authtentication */
+#endif
+
+#ifndef NX_HTTP_SERVER_NONCE_MAX
+#define NX_HTTP_SERVER_NONCE_MAX 2 /* The size of nonce for digest authtentication */
+#endif
+
+#ifndef NX_HTTP_SERVER_NONCE_TIMEOUT
+#define NX_HTTP_SERVER_NONCE_TIMEOUT (10 * NX_IP_PERIODIC_RATE)
+#endif
+
+/* Define the state of the nonce. */
+
+#define NX_HTTP_SERVER_NONCE_INVALID 0
+#define NX_HTTP_SERVER_NONCE_VALID 1
+#define NX_HTTP_SERVER_NONCE_ACCEPTED 2
+
/* NX_HTTP_MAX_STRING is base64 of "name:password" and plus 1 if an extra conversion is needed and plus 2 pad if needed. */
#define NX_HTTP_MAX_STRING ((NX_HTTP_MAX_NAME + NX_HTTP_MAX_PASSWORD + 1) * 4 / 3 + 1 + 2)
@@ -311,6 +333,17 @@ typedef struct NX_HTTP_SERVER_DATE_STRUCT
UCHAR nx_http_server_weekday; /* Weekday */
} NX_HTTP_SERVER_DATE;
+
+/* Define the nonce structure. */
+
+typedef struct NX_HTTP_SERVER_NONCE_STRUCT
+{
+ UINT nonce_state; /* The state of the nonce */
+ UINT nonce_timestamp; /* The time when the nonce is created */
+ UCHAR nonce_buffer[NX_HTTP_SERVER_NONCE_SIZE]; /* Nonce for digest authetication */
+} NX_HTTP_SERVER_NONCE;
+
+
/* Define the multipart context data structure. */
typedef struct NX_HTTP_SERVER_MULTIPART_STRUCT
@@ -369,6 +402,8 @@ typedef struct NX_HTTP_SERVER_STRUCT
TX_THREAD nx_http_server_thread; /* HTTP server thread */
#ifdef NX_HTTP_DIGEST_ENABLE
NX_MD5 nx_http_server_md5data; /* HTTP server MD5 work area */
+ NX_HTTP_SERVER_NONCE
+ nx_http_server_nonces[NX_HTTP_SERVER_NONCE_MAX];/* Nonce for digest authetication */
#endif /* NX_HTTP_DIGEST_ENABLE */
#ifdef NX_HTTP_MULTIPART_ENABLE
@@ -583,12 +618,14 @@ UINT _nx_http_server_retrieve_resource(NX_PACKET *packet_ptr, CHAR *desti
UINT _nx_http_server_calculate_content_offset(NX_PACKET *packet_ptr);
UINT _nx_http_server_type_get(NX_HTTP_SERVER *server_ptr, CHAR *name, CHAR *http_type_string);
UINT _nx_http_server_type_get_extended(NX_HTTP_SERVER *server_ptr, CHAR *name, UINT name_length, CHAR *http_type_string, UINT http_type_string_max_size);
+UINT _nx_http_server_disconnect(NX_HTTP_SERVER *http_server_ptr, UINT wait_option);
#ifdef NX_HTTP_DIGEST_ENABLE
UINT _nx_http_server_digest_authenticate(NX_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *name_ptr, UINT name_length, CHAR *password_ptr, UINT password_length, CHAR *realm_ptr, UINT realm_length, UINT *auth_request_present);
VOID _nx_http_server_digest_response_calculate(NX_HTTP_SERVER *server_ptr, CHAR *username, UINT username_length, CHAR *realm, UINT realm_length, CHAR *password, UINT password_length, CHAR *nonce, CHAR *method, CHAR *uri, CHAR *nc, CHAR *cnonce, CHAR *result);
-UINT _nx_http_server_retrieve_digest_authorization(NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce);
+UINT _nx_http_server_retrieve_digest_authorization(NX_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce, NX_HTTP_SERVER_NONCE **nonce_ptr);
VOID _nx_http_server_hex_ascii_convert(CHAR *source, UINT source_length, CHAR *destination);
+UINT _nx_http_server_nonce_allocate(NX_HTTP_SERVER *server_ptr, NX_HTTP_SERVER_NONCE **nonce_ptr);
#endif
#ifdef NX_HTTP_MULTIPART_ENABLE
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.c
index fd296441..015e6750 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.c
@@ -52,7 +52,9 @@ static UINT _nxd_mqtt_client_create_internal(NXD_MQTT_CLIENT *client_ptr, CHAR *
CHAR *client_id, UINT client_id_length,
NX_IP *ip_ptr, NX_PACKET_POOL *pool_ptr,
VOID *stack_ptr, ULONG stack_size, UINT mqtt_thread_priority);
-static UINT _nxd_mqtt_packet_allocate(NXD_MQTT_CLIENT *client_ptr, NX_PACKET **packet_ptr);
+static UINT _nxd_mqtt_packet_allocate(NXD_MQTT_CLIENT *client_ptr, NX_PACKET **packet_ptr, ULONG wait_option);
+static UINT _nxd_mqtt_packet_send(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr, UINT wait_option);
+static UINT _nxd_mqtt_packet_receive(NXD_MQTT_CLIENT *client_ptr, NX_PACKET **packet_ptr, UINT wait_option);
static UINT _nxd_mqtt_copy_transmit_packet(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr, NX_PACKET **new_packet_ptr,
USHORT packet_id, UCHAR set_duplicate_flag, UINT wait_option);
static VOID _nxd_mqtt_release_transmit_packet(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr, NX_PACKET *previous_packet_ptr);
@@ -246,7 +248,7 @@ ULONG bytes_copied;
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_client_sub_unsub PORTABLE C */
-/* 6.1.2 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -282,8 +284,7 @@ ULONG bytes_copied;
/* _nxd_mqtt_client_set_fixed_header */
/* _nxd_mqtt_client_append_message */
/* tx_mutex_put */
-/* nx_tcp_socket_send */
-/* nx_secure_tls_session_send */
+/* _nxd_mqtt_packet_send */
/* nx_packet_release */
/* _nxd_mqtt_copy_transmit_packet */
/* */
@@ -302,6 +303,12 @@ ULONG bytes_copied;
/* 11-09-2020 Yuxin Zhou Modified comment(s), and */
/* added packet id parameter, */
/* resulting in version 6.1.2 */
+/* 07-29-2022 Spencer McDonough Modified comment(s), */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
+/* 10-31-2022 Bo Chen Modified comment(s), improved */
+/* the logic of sending packet,*/
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nxd_mqtt_client_sub_unsub(NXD_MQTT_CLIENT *client_ptr, UINT op,
@@ -332,7 +339,7 @@ UCHAR temp_data[2];
return(NXD_MQTT_NOT_CONNECTED);
}
- status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr);
+ status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr, NX_WAIT_FOREVER);
if (status)
{
tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
@@ -461,19 +468,7 @@ UCHAR temp_data[2];
tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
/* Ready to send the connect message to the server. */
-#ifdef NX_SECURE_ENABLE
- if (client_ptr -> nxd_mqtt_client_use_tls)
- {
- status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, NX_WAIT_FOREVER);
- }
- else
- {
- status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, NX_WAIT_FOREVER);
- }
-#else
- status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, NX_WAIT_FOREVER);
-#endif /* NX_SECURE_ENABLE */
-
+ status = _nxd_mqtt_packet_send(client_ptr, packet_ptr, NX_WAIT_FOREVER);
if (status)
{
@@ -492,7 +487,7 @@ UCHAR temp_data[2];
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_packet_allocate PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -539,45 +534,202 @@ UCHAR temp_data[2];
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Spencer McDonough Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
+/* 10-31-2022 Bo Chen Modified comment(s), supported*/
+/* mqtt over websocket, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
-static UINT _nxd_mqtt_packet_allocate(NXD_MQTT_CLIENT *client_ptr, NX_PACKET **packet_ptr)
+static UINT _nxd_mqtt_packet_allocate(NXD_MQTT_CLIENT *client_ptr, NX_PACKET **packet_ptr, ULONG wait_option)
{
UINT status = NXD_MQTT_SUCCESS;
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+ if (client_ptr -> nxd_mqtt_client_use_websocket)
+ {
+
+ /* Use WebSocket packet allocate since it is able to count for WebSocket-related header space */
+ status = nx_websocket_client_packet_allocate(&(client_ptr -> nxd_mqtt_client_websocket), packet_ptr, wait_option);
+ }
+ else
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
#ifdef NX_SECURE_ENABLE
if (client_ptr -> nxd_mqtt_client_use_tls)
{
/* Use TLS packet allocate. The TLS packet allocate is able to count for
TLS-related header space including crypto initial vector area. */
status = nx_secure_tls_packet_allocate(&client_ptr -> nxd_mqtt_tls_session, client_ptr -> nxd_mqtt_client_packet_pool_ptr,
- packet_ptr, TX_WAIT_FOREVER);
+ packet_ptr, wait_option);
}
/* Allocate a packet */
else
{
-#endif
+#endif /* NX_SECURE_ENABLE */
if (client_ptr -> nxd_mqtt_client_socket.nx_tcp_socket_connect_ip.nxd_ip_version == NX_IP_VERSION_V4)
{
status = nx_packet_allocate(client_ptr -> nxd_mqtt_client_packet_pool_ptr, packet_ptr, NX_IPv4_TCP_PACKET,
- TX_WAIT_FOREVER);
+ wait_option);
}
else
{
status = nx_packet_allocate(client_ptr -> nxd_mqtt_client_packet_pool_ptr, packet_ptr, NX_IPv6_TCP_PACKET,
- TX_WAIT_FOREVER);
+ wait_option);
}
#ifdef NX_SECURE_ENABLE
}
-#endif
+#endif /* NX_SECURE_ENABLE */
if (status != NX_SUCCESS)
{
return(NXD_MQTT_PACKET_POOL_FAILURE);
}
+
return(NXD_MQTT_SUCCESS);
}
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _nxd_mqtt_packet_send PORTABLE C */
+/* 6.2.0 */
+/* AUTHOR */
+/* */
+/* Yuxin Zhou, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function sends out a packet. */
+/* */
+/* */
+/* INPUT */
+/* */
+/* client_ptr Pointer to MQTT Client */
+/* packet_ptr Pointer to packet */
+/* wait_option Timeout value */
+/* */
+/* OUTPUT */
+/* */
+/* status Completion status */
+/* */
+/* CALLS */
+/* */
+/* nx_websocket_client_send */
+/* nx_secure_tls_session_send */
+/* nx_tcp_socket_send */
+/* */
+/* CALLED BY */
+/* */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 10-31-2022 Bo Chen Initial Version 6.2.0 */
+/* */
+/**************************************************************************/
+static UINT _nxd_mqtt_packet_send(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr, UINT wait_option)
+{
+UINT status = NXD_MQTT_SUCCESS;
+
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+ if (client_ptr -> nxd_mqtt_client_use_websocket)
+ {
+ status = nx_websocket_client_send(&(client_ptr -> nxd_mqtt_client_websocket), packet_ptr, NX_WEBSOCKET_OPCODE_BINARY_FRAME, NX_TRUE, wait_option);
+ }
+ else
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
+#ifdef NX_SECURE_ENABLE
+ if (client_ptr -> nxd_mqtt_client_use_tls)
+ {
+ status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, wait_option);
+ }
+ else
+#endif /* NX_SECURE_ENABLE */
+ {
+ status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option);
+ }
+
+ return(status);
+}
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _nxd_mqtt_packet_receive PORTABLE C */
+/* 6.2.0 */
+/* AUTHOR */
+/* */
+/* Yuxin Zhou, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function receives a packet. */
+/* */
+/* */
+/* INPUT */
+/* */
+/* client_ptr Pointer to MQTT Client */
+/* packet_ptr Pointer to packet */
+/* wait_option Timeout value */
+/* */
+/* OUTPUT */
+/* */
+/* status Completion status */
+/* */
+/* CALLS */
+/* */
+/* nx_websocket_client_receive */
+/* nx_secure_tls_session_receive */
+/* nx_tcp_socket_receive */
+/* */
+/* CALLED BY */
+/* */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 10-31-2022 Bo Chen Initial Version 6.2.0 */
+/* */
+/**************************************************************************/
+static UINT _nxd_mqtt_packet_receive(NXD_MQTT_CLIENT *client_ptr, NX_PACKET **packet_ptr, UINT wait_option)
+{
+UINT status = NXD_MQTT_SUCCESS;
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+UINT op_code = 0;
+#endif /* NXD_MQTT_OVER_WEBSOCKET*/
+
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+ if (client_ptr -> nxd_mqtt_client_use_websocket)
+ {
+ status = nx_websocket_client_receive(&(client_ptr -> nxd_mqtt_client_websocket), packet_ptr, &op_code, wait_option);
+ if ((status == NX_SUCCESS) && (op_code != NX_WEBSOCKET_OPCODE_BINARY_FRAME))
+ {
+ return(NX_INVALID_PACKET);
+ }
+ }
+ else
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
+#ifdef NX_SECURE_ENABLE
+ if (client_ptr -> nxd_mqtt_client_use_tls)
+ {
+ status = nx_secure_tls_session_receive(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, wait_option);
+ }
+ else
+#endif /* NX_SECURE_ENABLE */
+ {
+ status = nx_tcp_socket_receive(&(client_ptr -> nxd_mqtt_client_socket), packet_ptr, wait_option);
+ }
+
+ return(status);
+}
+
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
@@ -1194,7 +1346,7 @@ ULONG bytes_copied;
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_process_publish PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -1219,7 +1371,7 @@ ULONG bytes_copied;
/* [receive_notify] User supplied receive */
/* callback function */
/* _nxd_mqtt_packet_allocate */
-/* nx_tcp_socket_send */
+/* _nxd_mqtt_packet_send */
/* nx_packet_release */
/* nx_secure_tls_session_send */
/* _nxd_mqtt_process_publish_packet */
@@ -1237,6 +1389,9 @@ ULONG bytes_copied;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Bo Chen Modified comment(s), improved */
+/* the logic of sending packet,*/
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
static UINT _nxd_mqtt_process_publish(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr)
@@ -1372,7 +1527,7 @@ ULONG bytes_copied;
/* Send out proper ACKs for QoS 1 and 2 messages. */
/* Allocate a new packet so we can send out a response. */
- status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr);
+ status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr, NX_WAIT_FOREVER);
if (status)
{
/* Packet allocation fails. */
@@ -1422,19 +1577,9 @@ ULONG bytes_copied;
}
tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
-#ifdef NX_SECURE_ENABLE
- if (client_ptr -> nxd_mqtt_client_use_tls)
- {
- status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, NX_WAIT_FOREVER);
- }
- else
- {
- status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, NX_WAIT_FOREVER);
- }
-#else
- status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, NX_WAIT_FOREVER);
-#endif /* NX_SECURE_ENABLE */
+ /* Send packet to server. */
+ status = _nxd_mqtt_packet_send(client_ptr, packet_ptr, NX_WAIT_FOREVER);
tx_mutex_get(client_ptr -> nxd_mqtt_client_mutex_ptr, TX_WAIT_FOREVER);
if (status)
@@ -1458,7 +1603,7 @@ ULONG bytes_copied;
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_process_publish_response PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -1482,8 +1627,7 @@ ULONG bytes_copied;
/* [nxd_mqtt_client_receive_notify] User supplied publish */
/* callback function */
/* _nxd_mqtt_release_transmit_packet */
-/* nx_tcp_socket_send */
-/* nx_secure_tls_session_send */
+/* _nxd_mqtt_packet_send */
/* */
/* */
/* CALLED BY */
@@ -1498,6 +1642,9 @@ ULONG bytes_copied;
/* 09-30-2020 Yuxin Zhou Modified comment(s), and */
/* added ack receive notify, */
/* resulting in version 6.1 */
+/* 10-31-2022 Bo Chen Modified comment(s), improved */
+/* the logic of sending packet,*/
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
static UINT _nxd_mqtt_process_publish_response(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr)
@@ -1573,7 +1720,7 @@ USHORT transmit_packet_id;
/* Send PUBCOMP */
/* Allocate a packet to send the response. */
- ret = _nxd_mqtt_packet_allocate(client_ptr, &response_packet);
+ ret = _nxd_mqtt_packet_allocate(client_ptr, &response_packet, NX_WAIT_FOREVER);
if (ret)
{
return(1);
@@ -1600,19 +1747,8 @@ USHORT transmit_packet_id;
tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
-#ifdef NX_SECURE_ENABLE
- if (client_ptr -> nxd_mqtt_client_use_tls)
- {
- ret = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), response_packet, NX_WAIT_FOREVER);
- }
- else
- {
- ret = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, response_packet, NX_WAIT_FOREVER);
- }
-#else
- ret = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, response_packet, NX_WAIT_FOREVER);
-
-#endif /* NX_SECURE_ENABLE */
+ /* Send packet to server. */
+ ret = _nxd_mqtt_packet_send(client_ptr, response_packet, NX_WAIT_FOREVER);
tx_mutex_get(client_ptr -> nxd_mqtt_client_mutex_ptr, TX_WAIT_FOREVER);
@@ -2008,7 +2144,7 @@ UCHAR fixed_header;
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_packet_receive_process PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -2049,6 +2185,9 @@ UCHAR fixed_header;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Bo Chen Modified comment(s), supported*/
+/* mqtt over websocket, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
static VOID _nxd_mqtt_packet_receive_process(NXD_MQTT_CLIENT *client_ptr)
@@ -2070,22 +2209,11 @@ ULONG packet_length;
tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
/* Make a receive call. */
-#ifdef NX_SECURE_ENABLE
- if (client_ptr -> nxd_mqtt_client_use_tls)
- {
- status = nx_secure_tls_session_receive(&(client_ptr -> nxd_mqtt_tls_session), &packet_ptr, NX_NO_WAIT);
- }
- else
- {
- status = nx_tcp_socket_receive(&client_ptr -> nxd_mqtt_client_socket, &packet_ptr, NX_NO_WAIT);
- }
-#else
- status = nx_tcp_socket_receive(&client_ptr -> nxd_mqtt_client_socket, &packet_ptr, NX_NO_WAIT);
-#endif /* NX_SECURE_ENABLE */
+ status = _nxd_mqtt_packet_receive(client_ptr, &packet_ptr, NX_NO_WAIT);
if (status != NX_SUCCESS)
{
- if (status != NX_NO_PACKET)
+ if ((status != NX_NO_PACKET) && (status != NX_CONTINUE))
{
/* Network issue. Close the MQTT session. */
@@ -2286,7 +2414,7 @@ ULONG packet_length;
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_tcp_establish_process PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -2320,6 +2448,9 @@ ULONG packet_length;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Bo Chen Modified comment(s), supported*/
+/* mqtt over websocket, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
static VOID _nxd_mqtt_tcp_establish_process(NXD_MQTT_CLIENT *client_ptr)
@@ -2357,6 +2488,36 @@ UINT status;
}
#endif /* NX_SECURE_ENABLE */
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+
+ /* If using websocket, start websocket connection. */
+ if (client_ptr -> nxd_mqtt_client_use_websocket)
+ {
+ status = nx_websocket_client_connect(&(client_ptr -> nxd_mqtt_client_websocket), &(client_ptr -> nxd_mqtt_client_socket),
+ client_ptr -> nxd_mqtt_client_websocket_host, client_ptr -> nxd_mqtt_client_websocket_host_length,
+ client_ptr -> nxd_mqtt_client_websocket_uri_path, client_ptr -> nxd_mqtt_client_websocket_uri_path_length,
+ (UCHAR *)NXD_MQTT_OVER_WEBSOCKET_PROTOCOL, sizeof(NXD_MQTT_OVER_WEBSOCKET_PROTOCOL) - 1,
+ NX_NO_WAIT);
+
+ if (status != NX_IN_PROGRESS)
+ {
+
+ /* End connection. */
+ _nxd_mqtt_client_connection_end(client_ptr, NX_NO_WAIT);
+
+ /* Check callback function. */
+ if (client_ptr -> nxd_mqtt_connect_notify)
+ {
+ client_ptr -> nxd_mqtt_connect_notify(client_ptr, status, client_ptr -> nxd_mqtt_connect_context);
+ }
+
+ return;
+ }
+
+ return;
+ }
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
/* Start to send MQTT connect packet. */
status = _nxd_mqtt_client_connect_packet_send(client_ptr, NX_NO_WAIT);
@@ -2382,7 +2543,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_tls_establish_process PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -2416,6 +2577,9 @@ UINT status;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Bo Chen Modified comment(s), supported*/
+/* mqtt over websocket, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
static VOID _nxd_mqtt_tls_establish_process(NXD_MQTT_CLIENT *client_ptr)
@@ -2429,29 +2593,40 @@ UINT status;
{
/* TLS session established. */
- client_ptr -> nxd_mqtt_tls_in_progress= NX_FALSE;
+ client_ptr -> nxd_mqtt_tls_in_progress = NX_FALSE;
- /* Start to send MQTT connect packet. */
- status = _nxd_mqtt_client_connect_packet_send(client_ptr, NX_NO_WAIT);
+#ifdef NXD_MQTT_OVER_WEBSOCKET
- /* Check status. */
- if (status)
+ /* If using websocket, start websocket connection. */
+ if (client_ptr -> nxd_mqtt_client_use_websocket)
{
+ status = nx_websocket_client_secure_connect(&(client_ptr -> nxd_mqtt_client_websocket), &(client_ptr -> nxd_mqtt_tls_session),
+ client_ptr -> nxd_mqtt_client_websocket_host, client_ptr -> nxd_mqtt_client_websocket_host_length,
+ client_ptr -> nxd_mqtt_client_websocket_uri_path, client_ptr -> nxd_mqtt_client_websocket_uri_path_length,
+ (UCHAR *)NXD_MQTT_OVER_WEBSOCKET_PROTOCOL, sizeof(NXD_MQTT_OVER_WEBSOCKET_PROTOCOL) - 1,
+ NX_NO_WAIT);
- /* End connection. */
- _nxd_mqtt_client_connection_end(client_ptr, NX_NO_WAIT);
-
- /* Check callback function. */
- if (client_ptr -> nxd_mqtt_connect_notify)
+ if (status == NX_IN_PROGRESS)
{
- client_ptr -> nxd_mqtt_connect_notify(client_ptr, status, client_ptr -> nxd_mqtt_connect_context);
+ return;
}
}
+ else
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+ {
+
+ /* Start to send MQTT connect packet. */
+ status = _nxd_mqtt_client_connect_packet_send(client_ptr, NX_NO_WAIT);
+ }
}
- else if (status != NX_CONTINUE)
+ else if (status == NX_CONTINUE)
{
+ return;
+ }
- /* Error. */
+ /* Check status. */
+ if (status)
+ {
/* End connection. */
_nxd_mqtt_client_connection_end(client_ptr, NX_NO_WAIT);
@@ -2545,7 +2720,7 @@ UCHAR len[2];
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_client_connection_end PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -2583,6 +2758,9 @@ UCHAR len[2];
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Bo Chen Modified comment(s), supported*/
+/* mqtt over websocket, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID _nxd_mqtt_client_connection_end(NXD_MQTT_CLIENT *client_ptr, ULONG wait_option)
@@ -2597,6 +2775,13 @@ VOID _nxd_mqtt_client_connection_end(NXD_MQTT_CLIENT *client_ptr, ULONG wait_opt
/* Release the mutex. */
tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+ if (client_ptr -> nxd_mqtt_client_use_websocket)
+ {
+ nx_websocket_client_disconnect(&(client_ptr -> nxd_mqtt_client_websocket), wait_option);
+ }
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
#ifdef NX_SECURE_ENABLE
if (client_ptr -> nxd_mqtt_client_use_tls)
{
@@ -3113,7 +3298,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_client_create_internal PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -3160,6 +3345,9 @@ UINT status;
/* 09-30-2020 Yuxin Zhou Modified comment(s), and */
/* corrected mqtt client state,*/
/* resulting in version 6.1 */
+/* 07-29-2022 Spencer McDonough Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
static UINT _nxd_mqtt_client_create_internal(NXD_MQTT_CLIENT *client_ptr, CHAR *client_name,
@@ -3167,7 +3355,9 @@ static UINT _nxd_mqtt_client_create_internal(NXD_MQTT_CLIENT *client_ptr, CHAR *
NX_IP *ip_ptr, NX_PACKET_POOL *pool_ptr,
VOID *stack_ptr, ULONG stack_size, UINT mqtt_thread_priority)
{
+#ifndef NXD_MQTT_CLOUD_ENABLE
UINT status;
+#endif /* NXD_MQTT_CLOUD_ENABLE */
#ifdef NXD_MQTT_CLOUD_ENABLE
NX_PARAMETER_NOT_USED(stack_ptr);
@@ -3229,26 +3419,10 @@ UINT status;
client_ptr -> nxd_mqtt_client_name = client_name;
/* Create the socket. */
- status = nx_tcp_socket_create(client_ptr -> nxd_mqtt_client_ip_ptr, &(client_ptr -> nxd_mqtt_client_socket), client_ptr -> nxd_mqtt_client_name,
- NX_IP_NORMAL, NX_DONT_FRAGMENT, 0x80, NXD_MQTT_CLIENT_SOCKET_WINDOW_SIZE,
- NX_NULL, _mqtt_client_disconnect_callback);
-
- /* Determine if an error occurred. */
- if (status != NX_SUCCESS)
- {
-#ifndef NXD_MQTT_CLOUD_ENABLE
- /* Delete the mutex. */
- tx_mutex_delete(&client_ptr -> nxd_mqtt_protection);
-
- /* Delete the event flags. */
- tx_event_flags_delete(&(client_ptr -> nxd_mqtt_events));
-
- /* Delete the thread. */
- tx_thread_delete(&(client_ptr -> nxd_mqtt_thread));
-#endif /* NXD_MQTT_CLOUD_ENABLE */
+ nx_tcp_socket_create(client_ptr -> nxd_mqtt_client_ip_ptr, &(client_ptr -> nxd_mqtt_client_socket), client_ptr -> nxd_mqtt_client_name,
+ NX_IP_NORMAL, NX_DONT_FRAGMENT, 0x80, NXD_MQTT_CLIENT_SOCKET_WINDOW_SIZE,
+ NX_NULL, _mqtt_client_disconnect_callback);
- return(NXD_MQTT_INTERNAL_ERROR);
- }
/* Record the client_ptr in the socket structure. */
client_ptr -> nxd_mqtt_client_socket.nx_tcp_socket_reserved_ptr = (VOID *)client_ptr;
@@ -3581,7 +3755,7 @@ UINT _nxde_mqtt_client_login_set(NXD_MQTT_CLIENT *client_ptr,
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_client_retransmit_message PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -3605,8 +3779,7 @@ UINT _nxde_mqtt_client_login_set(NXD_MQTT_CLIENT *client_ptr,
/* */
/* tx_mutex_get */
/* tx_mutex_put */
-/* nx_secure_tls_session_send */
-/* nx_tcp_socket_send */
+/* _nxd_mqtt_packet_send */
/* nx_packet_release */
/* tx_time_get */
/* nx_packet_copy */
@@ -3622,6 +3795,9 @@ UINT _nxde_mqtt_client_login_set(NXD_MQTT_CLIENT *client_ptr,
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Bo Chen Modified comment(s), improved */
+/* the logic of sending packet,*/
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
static UINT _nxd_mqtt_client_retransmit_message(NXD_MQTT_CLIENT *client_ptr, ULONG wait_option)
@@ -3653,20 +3829,8 @@ UCHAR fixed_header;
/* Release the mutex. */
tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
- /* Send the packet. */
-#ifdef NX_SECURE_ENABLE
- if (client_ptr -> nxd_mqtt_client_use_tls)
- {
- status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, wait_option);
- }
- else
- {
- status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option);
- }
-#else
- status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option);
-
-#endif /* NX_SECURE_ENABLE */
+ /* Send packet to server. */
+ status = _nxd_mqtt_packet_send(client_ptr, packet_ptr, wait_option);
if (status)
{
@@ -3701,7 +3865,7 @@ UCHAR fixed_header;
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_client_connect PORTABLE C */
-/* 6.1.8 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -3768,6 +3932,12 @@ UCHAR fixed_header;
/* corrected the logic for */
/* non-blocking mode, */
/* resulting in version 6.1.8 */
+/* 07-29-2022 Spencer McDonough Modified comment(s), and */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
+/* 10-31-2022 Bo Chen Modified comment(s), supported*/
+/* mqtt over websocket, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nxd_mqtt_client_connect(NXD_MQTT_CLIENT *client_ptr, NXD_ADDRESS *server_ip, UINT server_port,
@@ -3818,6 +3988,7 @@ UINT old_priority;
nx_secure_tls_session_delete(&(client_ptr -> nxd_mqtt_tls_session));
}
#endif /* NX_SECURE_ENABLE */
+ tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
return(NXD_MQTT_INVALID_STATE);
}
@@ -3840,20 +4011,8 @@ UINT old_priority;
client_ptr -> nxd_mqtt_ping_timeout = NXD_MQTT_PING_TIMEOUT_DELAY;
/* Create timer */
- status = tx_timer_create(&(client_ptr -> nxd_mqtt_timer), "MQTT Timer", _nxd_mqtt_periodic_timer_entry, (ULONG)client_ptr,
- client_ptr -> nxd_mqtt_timer_value, client_ptr -> nxd_mqtt_timer_value, TX_AUTO_ACTIVATE);
- if (status)
- {
-#ifdef NX_SECURE_ENABLE
- if (client_ptr -> nxd_mqtt_client_use_tls)
- {
- nx_secure_tls_session_delete(&(client_ptr -> nxd_mqtt_tls_session));
- }
-#endif /* NX_SECURE_ENABLE */
-
- tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
- return(NXD_MQTT_INTERNAL_ERROR);
- }
+ tx_timer_create(&(client_ptr -> nxd_mqtt_timer), "MQTT Timer", _nxd_mqtt_periodic_timer_entry, (ULONG)client_ptr,
+ client_ptr -> nxd_mqtt_timer_value, client_ptr -> nxd_mqtt_timer_value, TX_AUTO_ACTIVATE);
}
else
{
@@ -3867,49 +4026,41 @@ UINT old_priority;
/* Set TCP connection establish notify for non-blocking mode. */
if (wait_option == 0)
{
- status = nx_tcp_socket_establish_notify(&client_ptr -> nxd_mqtt_client_socket, _nxd_mqtt_tcp_establish_notify);
+ nx_tcp_socket_establish_notify(&client_ptr -> nxd_mqtt_client_socket, _nxd_mqtt_tcp_establish_notify);
- /* Check status. */
- if (status != NX_SUCCESS)
+ /* Set the receive callback. */
+ nx_tcp_socket_receive_notify(&client_ptr -> nxd_mqtt_client_socket, _nxd_mqtt_receive_callback);
+
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+ if (client_ptr -> nxd_mqtt_client_use_websocket)
{
-#ifdef NX_SECURE_ENABLE
- if (client_ptr -> nxd_mqtt_client_use_tls)
- {
- nx_secure_tls_session_delete(&(client_ptr -> nxd_mqtt_tls_session));
- }
-#endif /* NX_SECURE_ENABLE */
- tx_timer_delete(&(client_ptr -> nxd_mqtt_timer));
- tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
- return(status);
- }
- /* Set the receive callback. */
- nx_tcp_socket_receive_notify(&client_ptr -> nxd_mqtt_client_socket, _nxd_mqtt_receive_callback);
+ /* Set the websocket connection callback. */
+ nx_websocket_client_connection_status_callback_set(&client_ptr -> nxd_mqtt_client_websocket, client_ptr, _nxd_mqtt_client_websocket_connection_status_callback);
+ }
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
}
else
{
/* Clean receive callback. */
client_ptr -> nxd_mqtt_client_socket.nx_tcp_receive_callback = NX_NULL;
+
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+ if (client_ptr -> nxd_mqtt_client_use_websocket)
+ {
+
+ /* Clean the websocket connection callback. */
+ nx_websocket_client_connection_status_callback_set(&client_ptr -> nxd_mqtt_client_websocket, NX_NULL, NX_NULL);
+ }
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
}
/* Release mutex */
tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
/* First attempt to bind the client socket. */
- status = nx_tcp_client_socket_bind(&(client_ptr -> nxd_mqtt_client_socket), NX_ANY_PORT, wait_option);
-
- if (status != NX_SUCCESS)
- {
-#ifdef NX_SECURE_ENABLE
- if (client_ptr -> nxd_mqtt_client_use_tls)
- {
- nx_secure_tls_session_delete(&(client_ptr -> nxd_mqtt_tls_session));
- }
-#endif /* NX_SECURE_ENABLE */
- tx_timer_delete(&(client_ptr -> nxd_mqtt_timer));
- return(NXD_MQTT_INTERNAL_ERROR);
- }
+ nx_tcp_client_socket_bind(&(client_ptr -> nxd_mqtt_client_socket), NX_ANY_PORT, wait_option);
/* Obtain the mutex. */
tx_mutex_get(client_ptr -> nxd_mqtt_client_mutex_ptr, NX_WAIT_FOREVER);
@@ -3946,7 +4097,7 @@ UINT old_priority;
}
/* Just return for non-blocking mode. */
- if ((status == NX_IN_PROGRESS) || (wait_option == 0))
+ if (wait_option == 0)
{
return(NX_IN_PROGRESS);
}
@@ -3982,6 +4133,43 @@ UINT old_priority;
}
#endif /* NX_SECURE_ENABLE */
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+ if (client_ptr -> nxd_mqtt_client_use_websocket)
+ {
+#ifdef NX_SECURE_ENABLE
+ if (client_ptr -> nxd_mqtt_client_use_tls)
+ {
+ status = nx_websocket_client_secure_connect(&(client_ptr -> nxd_mqtt_client_websocket), &(client_ptr -> nxd_mqtt_tls_session),
+ client_ptr -> nxd_mqtt_client_websocket_host, client_ptr -> nxd_mqtt_client_websocket_host_length,
+ client_ptr -> nxd_mqtt_client_websocket_uri_path, client_ptr -> nxd_mqtt_client_websocket_uri_path_length,
+ (UCHAR *)NXD_MQTT_OVER_WEBSOCKET_PROTOCOL, sizeof(NXD_MQTT_OVER_WEBSOCKET_PROTOCOL) - 1,
+ wait_option);
+ }
+ else
+#endif /* NX_SECURE_ENABLE */
+ {
+ status = nx_websocket_client_connect(&(client_ptr -> nxd_mqtt_client_websocket), &(client_ptr -> nxd_mqtt_client_socket),
+ client_ptr -> nxd_mqtt_client_websocket_host, client_ptr -> nxd_mqtt_client_websocket_host_length,
+ client_ptr -> nxd_mqtt_client_websocket_uri_path, client_ptr -> nxd_mqtt_client_websocket_uri_path_length,
+ (UCHAR *)NXD_MQTT_OVER_WEBSOCKET_PROTOCOL, sizeof(NXD_MQTT_OVER_WEBSOCKET_PROTOCOL) - 1,
+ wait_option);
+ }
+
+ if (status != NX_SUCCESS)
+ {
+
+ /* Revert thread priority. */
+ tx_thread_priority_change(tx_thread_identify(), old_priority, &old_priority);
+
+ /* End connection. */
+ _nxd_mqtt_client_connection_end(client_ptr, NX_NO_WAIT);
+
+ return(NXD_MQTT_CONNECT_FAILURE);
+ }
+ }
+
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
/* Start to send connect packet. */
status = _nxd_mqtt_client_connect_packet_send(client_ptr, wait_option);
@@ -3993,22 +4181,11 @@ UINT old_priority;
/* End connection. */
_nxd_mqtt_client_connection_end(client_ptr, NX_NO_WAIT);
-
return(NXD_MQTT_CONNECT_FAILURE);
}
-#ifdef NX_SECURE_ENABLE
- if (client_ptr -> nxd_mqtt_client_use_tls)
- {
- status = nx_secure_tls_session_receive(&(client_ptr -> nxd_mqtt_tls_session), &packet_ptr, wait_option);
- }
- else
- {
- status = nx_tcp_socket_receive(&client_ptr -> nxd_mqtt_client_socket, &packet_ptr, wait_option);
- }
-#else
- status = nx_tcp_socket_receive(&client_ptr -> nxd_mqtt_client_socket, &packet_ptr, wait_option);
-#endif /* NX_SECURE_ENABLE */
+ /* Call a receive. */
+ status = _nxd_mqtt_packet_receive(client_ptr, &packet_ptr, wait_option);
/* Revert thread priority. */
tx_thread_priority_change(tx_thread_identify(), old_priority, &old_priority);
@@ -4044,7 +4221,7 @@ UINT old_priority;
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_client_connect_packet_send PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -4069,13 +4246,12 @@ UINT old_priority;
/* CALLS */
/* */
/* nx_packet_release */
-/* nx_tcp_socket_send */
-/* nx_secure_tls_session_send */
/* _nxd_mqtt_packet_allocate */
/* _nxd_mqtt_release_transmit_packet */
/* _nxd_mqtt_client_connection_end */
/* _nxd_mqtt_client_set_fixed_header */
/* _nxd_mqtt_client_append_message */
+/* _nxd_mqtt_packet_send */
/* */
/* CALLED BY */
/* */
@@ -4090,6 +4266,12 @@ UINT old_priority;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Spencer McDonough Modified comment(s), */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
+/* 10-31-2022 Bo Chen Modified comment(s), improved */
+/* the logic of sending packet,*/
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nxd_mqtt_client_connect_packet_send(NXD_MQTT_CLIENT *client_ptr, ULONG wait_option)
@@ -4167,10 +4349,10 @@ UINT keepalive = (client_ptr -> nxd_mqtt_keepalive/NX_IP_PERIODI
return(NXD_MQTT_INTERNAL_ERROR);
}
- status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr);
+ status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr, wait_option);
+
if (status)
{
-
return(status);
}
@@ -4182,21 +4364,18 @@ UINT keepalive = (client_ptr -> nxd_mqtt_keepalive/NX_IP_PERIODI
if (ret)
{
-
/* Release the packet. */
nx_packet_release(packet_ptr);
-
return(NXD_MQTT_PACKET_POOL_FAILURE);
}
-
+
+ /* Fill in protocol name. */
ret = _nxd_mqtt_client_append_message(client_ptr, packet_ptr, "MQTT", 4, wait_option);
if (ret)
{
-
/* Release the packet. */
nx_packet_release(packet_ptr);
-
return(NXD_MQTT_PACKET_POOL_FAILURE);
}
@@ -4263,19 +4442,7 @@ UINT keepalive = (client_ptr -> nxd_mqtt_keepalive/NX_IP_PERIODI
}
/* Ready to send the connect message to the server. */
-#ifdef NX_SECURE_ENABLE
- if (client_ptr -> nxd_mqtt_client_use_tls)
- {
- status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, wait_option);
- }
- else
- {
- status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option);
- }
-#else
- status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option);
-
-#endif /* NX_SECURE_ENABLE */
+ status = _nxd_mqtt_packet_send(client_ptr, packet_ptr, wait_option);
if (status)
{
@@ -4383,7 +4550,7 @@ UINT ret;
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_client_delete PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -4420,6 +4587,9 @@ UINT ret;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Bo Chen Modified comment(s), supported*/
+/* mqtt over websocket, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nxd_mqtt_client_delete(NXD_MQTT_CLIENT *client_ptr)
@@ -4452,6 +4622,14 @@ UINT _nxd_mqtt_client_delete(NXD_MQTT_CLIENT *client_ptr)
nx_cloud_delete(&(client_ptr -> nxd_mqtt_client_cloud));
#endif /* NXD_MQTT_CLOUD_ENABLE */
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+ if (client_ptr -> nxd_mqtt_client_use_websocket)
+ {
+ nx_websocket_client_delete(&client_ptr -> nxd_mqtt_client_websocket);
+ client_ptr -> nxd_mqtt_client_use_websocket = NX_FALSE;
+ }
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
return(NXD_MQTT_SUCCESS);
}
@@ -4460,7 +4638,7 @@ UINT _nxd_mqtt_client_delete(NXD_MQTT_CLIENT *client_ptr)
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_client_publish_packet_send PORTABLE C */
-/* 6.1.8 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -4486,10 +4664,9 @@ UINT _nxd_mqtt_client_delete(NXD_MQTT_CLIENT *client_ptr)
/* */
/* tx_mutex_get */
/* tx_mutex_put */
-/* nx_tcp_socket_send */
-/* nx_secure_tls_session_send */
/* nx_packet_release */
/* _nxd_mqtt_copy_transmit_packet */
+/* _nxd_mqtt_packet_send */
/* */
/* CALLED BY */
/* */
@@ -4506,6 +4683,9 @@ UINT _nxd_mqtt_client_delete(NXD_MQTT_CLIENT *client_ptr)
/* supported maximum transmit */
/* queue depth, */
/* resulting in version 6.1.8 */
+/* 10-31-2022 Bo Chen Modified comment(s), improved */
+/* the logic of sending packet,*/
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nxd_mqtt_client_publish_packet_send(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr,
@@ -4571,19 +4751,7 @@ UINT ret = NXD_MQTT_SUCCESS;
tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
/* Ready to send the connect message to the server. */
-#ifdef NX_SECURE_ENABLE
- if (client_ptr -> nxd_mqtt_client_use_tls)
- {
- status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, wait_option);
- }
- else
- {
- status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option);
- }
-#else
- status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option);
-
-#endif /* NX_SECURE_ENABLE */
+ status = _nxd_mqtt_packet_send(client_ptr, packet_ptr, wait_option);
if (status)
{
@@ -4598,7 +4766,7 @@ UINT ret = NXD_MQTT_SUCCESS;
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_client_publish PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -4647,6 +4815,9 @@ UINT ret = NXD_MQTT_SUCCESS;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Spencer McDonough Modified comment(s), */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nxd_mqtt_client_publish(NXD_MQTT_CLIENT *client_ptr, CHAR *topic_name, UINT topic_name_length,
@@ -4672,7 +4843,7 @@ UINT ret = NXD_MQTT_SUCCESS;
return(NXD_MQTT_NOT_CONNECTED);
}
- status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr);
+ status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr, wait_option);
if (status != NXD_MQTT_SUCCESS)
{
@@ -4925,7 +5096,7 @@ UINT _nxd_mqtt_client_unsubscribe(NXD_MQTT_CLIENT *client_ptr, CHAR *topic_name,
/* FUNCTION RELEASE */
/* */
/* _nxd_mqtt_send_simple_message PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -4951,8 +5122,7 @@ UINT _nxd_mqtt_client_unsubscribe(NXD_MQTT_CLIENT *client_ptr, CHAR *topic_name,
/* tx_mutex_get */
/* _nxd_mqtt_packet_allocate */
/* tx_mutex_put */
-/* nx_tcp_socket_send */
-/* nx_secure_tls_session_send */
+/* _nxd_mqtt_packet_send */
/* nx_packet_release */
/* */
/* CALLED BY */
@@ -4967,6 +5137,12 @@ UINT _nxd_mqtt_client_unsubscribe(NXD_MQTT_CLIENT *client_ptr, CHAR *topic_name,
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Spencer McDonough Modified comment(s), */
+/* improved internal logic, */
+/* resulting in version 6.1.12 */
+/* 10-31-2022 Bo Chen Modified comment(s), improved */
+/* the logic of sending packet,*/
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
static UINT _nxd_mqtt_send_simple_message(NXD_MQTT_CLIENT *client_ptr, UCHAR header_value)
@@ -4977,7 +5153,7 @@ UINT status;
UINT status_mutex;
UCHAR *byte;
- status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr);
+ status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr, NX_WAIT_FOREVER);
if (status)
{
return(NXD_MQTT_INTERNAL_ERROR);
@@ -5002,20 +5178,9 @@ UCHAR *byte;
/* Release MQTT protection before making NetX/TLS calls. */
tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
-#ifdef NX_SECURE_ENABLE
- if (client_ptr -> nxd_mqtt_client_use_tls)
- {
- status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, NX_WAIT_FOREVER);
- }
- else
- {
- status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, NX_WAIT_FOREVER);
- }
-#else
- status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, NX_WAIT_FOREVER);
-
-#endif /* NX_SECURE_ENABLE */
+ /* Send packet to server. */
+ status = _nxd_mqtt_packet_send(client_ptr, packet_ptr, NX_WAIT_FOREVER);
status_mutex = tx_mutex_get(client_ptr -> nxd_mqtt_client_mutex_ptr, NX_WAIT_FOREVER);
if (status)
@@ -6202,3 +6367,207 @@ UINT status;
return(NXD_MQTT_SUCCESS);
}
#endif /* NXD_MQTT_CLOUD_ENABLE */
+
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _nxd_mqtt_client_websocket_connection_status_callback */
+/* PORTABLE C */
+/* 6.2.0 */
+/* AUTHOR */
+/* */
+/* Yuxin Zhou, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function is the websocket connection status callback. */
+/* */
+/* INPUT */
+/* */
+/* websocket_client_ptr Pointer to websocket client */
+/* context Pointer to MQTT client */
+/* status Websocket connection status */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* _nxd_mqtt_client_connect_packet_send */
+/* _nxd_mqtt_client_connection_end */
+/* */
+/* CALLED BY */
+/* */
+/* _nxd_mqtt_client_event_process */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 10-31-2022 Yuxin Zhou Initial Version 6.2.0 */
+/* */
+/**************************************************************************/
+VOID _nxd_mqtt_client_websocket_connection_status_callback(NX_WEBSOCKET_CLIENT *websocket_client_ptr, VOID *context, UINT status)
+{
+NXD_MQTT_CLIENT *client_ptr = (NXD_MQTT_CLIENT *)context;
+
+
+ NX_PARAMETER_NOT_USED(websocket_client_ptr);
+
+ if (status == NX_SUCCESS)
+ {
+
+ /* Start to send MQTT connect packet. */
+ status = _nxd_mqtt_client_connect_packet_send(client_ptr, NX_NO_WAIT);
+ }
+
+ /* If an error occurs. */
+ if (status)
+ {
+
+ /* End connection. */
+ _nxd_mqtt_client_connection_end(client_ptr, NX_NO_WAIT);
+
+ /* Check callback function. */
+ if (client_ptr -> nxd_mqtt_connect_notify)
+ {
+ client_ptr -> nxd_mqtt_connect_notify(client_ptr, status, client_ptr -> nxd_mqtt_connect_context);
+ }
+ }
+}
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _nxd_mqtt_client_websocket_set PORTABLE C */
+/* 6.2.0 */
+/* AUTHOR */
+/* */
+/* Yuxin Zhou, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function sets the websocket. */
+/* */
+/* INPUT */
+/* */
+/* client_ptr Pointer to MQTT Client */
+/* host Host used by the client */
+/* host_length Length of host, in bytes */
+/* uri_path URI path used by the client */
+/* uri_path_length Length of uri path, in bytes */
+/* */
+/* OUTPUT */
+/* */
+/* status Completion status */
+/* */
+/* CALLS */
+/* */
+/* None */
+/* */
+/* CALLED BY */
+/* */
+/* Application Code */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 10-31-2022 Yuxin Zhou Initial Version 6.2.0 */
+/* */
+/**************************************************************************/
+UINT _nxd_mqtt_client_websocket_set(NXD_MQTT_CLIENT *client_ptr, UCHAR *host, UINT host_length, UCHAR *uri_path, UINT uri_path_length)
+{
+UINT status;
+
+ /* Obtain the mutex. */
+ status = tx_mutex_get(client_ptr -> nxd_mqtt_client_mutex_ptr, NX_WAIT_FOREVER);
+
+ if (status != TX_SUCCESS)
+ {
+ return(NXD_MQTT_MUTEX_FAILURE);
+ }
+
+ /* Set the host info. */
+ client_ptr -> nxd_mqtt_client_websocket_host = host;
+ client_ptr -> nxd_mqtt_client_websocket_host_length = host_length;
+ client_ptr -> nxd_mqtt_client_websocket_uri_path = uri_path;
+ client_ptr -> nxd_mqtt_client_websocket_uri_path_length = uri_path_length;
+
+ /* Create WebSocket. */
+ status = nx_websocket_client_create(&client_ptr -> nxd_mqtt_client_websocket, (UCHAR *)"",
+ client_ptr -> nxd_mqtt_client_ip_ptr,
+ client_ptr -> nxd_mqtt_client_packet_pool_ptr);
+
+ /* Check status. */
+ if (status)
+ {
+ tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
+ return(status);
+ }
+
+ client_ptr -> nxd_mqtt_client_use_websocket = NX_TRUE;
+
+ tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
+ return(NXD_MQTT_SUCCESS);
+}
+
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _nxde_mqtt_client_websocket_set PORTABLE C */
+/* 6.2.0 */
+/* AUTHOR */
+/* */
+/* Yuxin Zhou, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function checks for errors in setting MQTT client websocket. */
+/* */
+/* INPUT */
+/* */
+/* client_ptr Pointer to MQTT Client */
+/* host Host used by the client */
+/* host_length Length of host, in bytes */
+/* uri_path URI path used by the client */
+/* uri_path_length Length of uri path, in bytes */
+/* */
+/* OUTPUT */
+/* */
+/* status Completion status */
+/* */
+/* CALLS */
+/* */
+/* _nxd_mqtt_client_websocket_set */
+/* */
+/* CALLED BY */
+/* */
+/* Application Code */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 10-31-2022 Yuxin Zhou Initial Version 6.2.0 */
+/* */
+/**************************************************************************/
+UINT _nxde_mqtt_client_websocket_set(NXD_MQTT_CLIENT *client_ptr, UCHAR *host, UINT host_length, UCHAR *uri_path, UINT uri_path_length)
+{
+
+ /* Validate the parameters. */
+ if ((client_ptr == NX_NULL) || (host == NX_NULL) || (host_length == 0) ||
+ (uri_path == NX_NULL) || (uri_path_length == 0))
+ {
+ return(NX_PTR_ERROR);
+ }
+
+ return(_nxd_mqtt_client_websocket_set(client_ptr, host, host_length, uri_path, uri_path_length));
+}
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.h
index e35c3a2f..9327a779 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.h
@@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* nxd_mqtt_client.h PORTABLE C */
-/* 6.1.9 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -55,6 +55,9 @@
/* 10-15-2021 Yuxin Zhou Modified comment(s), included */
/* necessary header file, */
/* resulting in version 6.1.9 */
+/* 10-31-2022 Bo Chen Modified comment(s), supported*/
+/* mqtt over websocket, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -87,11 +90,18 @@ extern "C" {
#endif /* NX_SECURE_ENABLE */
#endif /* NXD_MQTT_REQUIRE_TLS */
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+#include "nx_websocket_client.h"
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
/* Defined, MQTT transmit queue depth is enabled. It must be positive integer. */
/*
#define NXD_MQTT_MAXIMUM_TRANSMIT_QUEUE_DEPTH 20
*/
+/* Define MQTT protocol for websocket. */
+#define NXD_MQTT_OVER_WEBSOCKET_PROTOCOL "mqtt"
+
/* Define memcpy, memset and memcmp functions used internal. */
#ifndef NXD_MQTT_SECURE_MEMCPY
#define NXD_MQTT_SECURE_MEMCPY memcpy
@@ -159,6 +169,9 @@ extern "C" {
/* Define the default MQTT TLS (secure) port number */
#define NXD_MQTT_TLS_PORT 8883
+/* Define the default MQTT TLS (secure) over WebSocket port number */
+#define NXD_MQTT_OVER_WEBSOCKET_TLS_PORT 443
+
#define MQTT_PROTOCOL_LEVEL 4
@@ -368,6 +381,14 @@ typedef struct NXD_MQTT_CLIENT_STRUCT
NX_SECURE_TLS_SESSION nxd_mqtt_tls_session;
UINT nxd_mqtt_tls_in_progress;
#endif
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+ UINT nxd_mqtt_client_use_websocket;
+ NX_WEBSOCKET_CLIENT nxd_mqtt_client_websocket;
+ UCHAR *nxd_mqtt_client_websocket_host;
+ UINT nxd_mqtt_client_websocket_host_length;
+ UCHAR *nxd_mqtt_client_websocket_uri_path;
+ UINT nxd_mqtt_client_websocket_uri_path_length;
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
} NXD_MQTT_CLIENT;
@@ -396,6 +417,9 @@ typedef struct NXD_MQTT_CLIENT_STRUCT
#define nxd_mqtt_client_receive_notify_set _nxd_mqtt_client_receive_notify_set
#define nxd_mqtt_client_message_get _nxd_mqtt_client_message_get
#define nxd_mqtt_client_disconnect_notify_set _nxd_mqtt_client_disconnect_notify_set
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+#define nxd_mqtt_client_websocket_set _nxd_mqtt_client_websocket_set
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
#else /* if !NXD_MQTT_CLIENT_SOURCE_CODE */
#define nxd_mqtt_client_create _nxde_mqtt_client_create
@@ -411,6 +435,9 @@ typedef struct NXD_MQTT_CLIENT_STRUCT
#define nxd_mqtt_client_receive_notify_set _nxde_mqtt_client_receive_notify_set
#define nxd_mqtt_client_message_get _nxde_mqtt_client_message_get
#define nxd_mqtt_client_disconnect_notify_set _nxde_mqtt_client_disconnect_notify_set
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+#define nxd_mqtt_client_websocket_set _nxde_mqtt_client_websocket_set
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
#endif /* NX_DISABLE_ERROR_CHECKING */
@@ -444,6 +471,9 @@ UINT nxd_mqtt_client_disconnect(NXD_MQTT_CLIENT *client_ptr);
UINT nxd_mqtt_client_delete(NXD_MQTT_CLIENT *client_ptr);
UINT nxd_mqtt_client_disconnect_notify_set(NXD_MQTT_CLIENT *client_ptr, VOID (*disconnect_notify)(NXD_MQTT_CLIENT *));
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+UINT nxd_mqtt_client_websocket_set(NXD_MQTT_CLIENT *client_ptr, UCHAR *host, UINT host_length, UCHAR *uri_path, UINT uri_path_length);
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
#else /* ifdef NXD_MQTT_CLIENT_SOURCE_CODE */
@@ -517,6 +547,12 @@ UINT _nxde_mqtt_client_secure_connect(NXD_MQTT_CLIENT *client_ptr, NXD_ADDRESS *
UINT keepalive, UINT clean_session, ULONG timeout);
#endif /* NX_SECURE_ENABLE */
+#ifdef NXD_MQTT_OVER_WEBSOCKET
+UINT _nxd_mqtt_client_websocket_set(NXD_MQTT_CLIENT *client_ptr, UCHAR *host, UINT host_length, UCHAR *uri_path, UINT uri_path_length);
+UINT _nxde_mqtt_client_websocket_set(NXD_MQTT_CLIENT *client_ptr, UCHAR *host, UINT host_length, UCHAR *uri_path, UINT uri_path_length);
+VOID _nxd_mqtt_client_websocket_connection_status_callback(NX_WEBSOCKET_CLIENT *websocket_client_ptr, VOID *context, UINT status);
+#endif /* NXD_MQTT_OVER_WEBSOCKET */
+
#endif /* ifndef NXD_MQTT_CLIENT_SOURCE_CODE */
#ifdef NXD_MQTT_CLOUD_ENABLE
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/snmp/nxd_snmp.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/snmp/nxd_snmp.c
index a7660db5..c9453b36 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/snmp/nxd_snmp.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/snmp/nxd_snmp.c
@@ -15145,7 +15145,7 @@ UCHAR encoding_started;
/* FUNCTION RELEASE */
/* */
/* _nx_snmp_utility_object_data_get PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -15182,6 +15182,9 @@ UCHAR encoding_started;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* fixed compiler warnings, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_snmp_utility_object_data_get(UCHAR *buffer_ptr, NX_SNMP_OBJECT_DATA *object_data, INT buffer_length)
@@ -15189,9 +15192,9 @@ UINT _nx_snmp_utility_object_data_get(UCHAR *buffer_ptr, NX_SNMP_OBJECT_DATA *o
UINT i;
-UINT length;
+UINT length = 0;
LONG data;
-UINT total;
+UINT total = 0;
CHAR byte;
LONG temp = 0;
USHORT tlv_type, tlv_tag_class;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/sntp/nxd_sntp_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/sntp/nxd_sntp_client.c
index 7bc1a313..c275ea54 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/sntp/nxd_sntp_client.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/sntp/nxd_sntp_client.c
@@ -2432,7 +2432,7 @@ NX_SNTP_TIME local_time;
/* FUNCTION RELEASE */
/* */
/* _nx_sntp_client_receive_time_update PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -2480,6 +2480,9 @@ NX_SNTP_TIME local_time;
/* added support for disabling */
/* message check, */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* corrected the port check, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_sntp_client_receive_time_update(NX_SNTP_CLIENT *client_ptr, ULONG timeout)
@@ -2521,7 +2524,7 @@ NXD_ADDRESS source_ip_address, destination_ip_address;
sender_port = (UINT)udp_header_ptr -> nx_udp_header_word_0 >> NX_SHIFT_BY_16;
/* Check if this is the server port the Client expects. */
- if (sender_port != NX_SNTP_CLIENT_UDP_PORT)
+ if (sender_port != NX_SNTP_SERVER_UDP_PORT)
{
/* No, reject the packet. */
@@ -4846,7 +4849,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_sntp_client_utility_display_date_time PORTABLE C */
-/* 6.1.8 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -4893,6 +4896,9 @@ UINT status;
/* improved the logic of */
/* converting number to string,*/
/* resulting in version 6.1.8 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), fixed */
+/* the typo of August string, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_sntp_client_utility_display_date_time(NX_SNTP_CLIENT *client_ptr, CHAR *buffer, UINT length)
@@ -4903,7 +4909,7 @@ UINT offset;
UINT return_length;
NX_SNTP_DATE_TIME DisplayTime;
const CHAR *months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aud", "Sep", "Oct", "Nov", "Dec"};
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
#ifndef NX_SNTP_CURRENT_YEAR
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_tcpserver.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_tcpserver.c
index 9169e82a..409d2d72 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_tcpserver.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_tcpserver.c
@@ -352,7 +352,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_tcpserver_tls_setup PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -436,6 +436,10 @@ UINT status;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* corrected the index of the */
+/* remote certificate list, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@@ -530,7 +534,7 @@ UINT status;
for(cert_count = 0; cert_count < remote_certs_num; ++cert_count)
{
/* Allocate a remote certificate from the provided array. */
- status = nx_secure_tls_remote_certificate_allocate(tls_session, remote_certificates[i],
+ status = nx_secure_tls_remote_certificate_allocate(tls_session, remote_certificates[cert_count],
session_cert_buffer, session_cert_buffer_size);
if(status != NX_SUCCESS)
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_client.c
index 2ef47e89..d5becc3c 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_client.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_client.c
@@ -2614,7 +2614,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_web_http_client_request_packet_send PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -2651,6 +2651,9 @@ UINT status;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), fixed */
+/* the invalid release issue, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_web_http_client_request_packet_send(NX_WEB_HTTP_CLIENT *client_ptr, NX_PACKET *packet_ptr, UINT more_data, ULONG wait_option)
@@ -2693,9 +2696,6 @@ UINT length = packet_ptr -> nx_packet_length;
/* No, send was not successful. */
- /* Release the packet. */
- nx_packet_release(packet_ptr);
-
/* Disconnect and unbind the socket. */
_nx_web_http_client_error_exit(client_ptr, wait_option);
@@ -5824,7 +5824,7 @@ UINT header_size;
/* FUNCTION RELEASE */
/* */
/* _nx_web_http_client_put_packet PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -5863,6 +5863,9 @@ UINT header_size;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), fixed */
+/* the invalid release issue, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_web_http_client_put_packet(NX_WEB_HTTP_CLIENT *client_ptr, NX_PACKET *packet_ptr, ULONG wait_option)
@@ -5943,9 +5946,6 @@ UINT status;
{
/* No, send was not successful. */
-
- /* Release the packet. */
- nx_packet_release(packet_ptr);
/* Disconnect and unbind the socket. */
_nx_web_http_client_error_exit(client_ptr, wait_option);
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.c
index 588569f2..7e2c5837 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.c
@@ -47,10 +47,9 @@
#endif /* NX_WEB_HTTP_SERVER_OMIT_CONTENT_LENGTH */
#ifdef NX_WEB_HTTP_DIGEST_ENABLE
-/* Define the default nonce, used only for MD5 authentication. For security reasons, this ASCII value should
- change over time. */
-CHAR _nx_web_http_server_nonce[] = "a4b8c8d7e0f6a7b2c3d2e4f5a4b7c5d2e7f";
+/* Use for mapping random nonces to printable characters. */
+static CHAR _nx_web_http_server_base64_array[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
#endif
/* Define date strings. */
@@ -3116,7 +3115,7 @@ NX_WEB_HTTP_SERVER *server_ptr;
/* */
/* FUNCTION RELEASE */
/* */
-/* _nx_web_http_server_connection_present PORTABLE C */
+/* _nx_web_http_server_receive_data PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
@@ -5153,7 +5152,7 @@ NX_PACKET *packet_ptr;
/* FUNCTION RELEASE */
/* */
/* _nx_web_http_server_basic_authenticate PORTABLE C */
-/* 6.1.6 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -5208,6 +5207,10 @@ NX_PACKET *packet_ptr;
/* improved the logic of */
/* parsing base64, */
/* resulting in version 6.1.6 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), fixed */
+/* the issue of processing */
+/* empty password, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_web_http_server_basic_authenticate(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *name_ptr, CHAR *password_ptr, CHAR *realm_ptr, UINT *auth_request_present)
@@ -5290,7 +5293,9 @@ UINT authorization_decoded_size;
}
/* Determine if we have a match. */
- if (match && (i == authorization_decoded_size) && (authorization_decoded[i] == (CHAR) NX_NULL))
+ if (match && (i == authorization_decoded_size) &&
+ (authorization_decoded[i] == (CHAR) NX_NULL) &&
+ (password_ptr[j] == (CHAR) NX_NULL))
{
/* Yes, we have successful authorization!! */
@@ -6254,13 +6259,110 @@ UINT temp_name_length;
return(NX_WEB_HTTP_EXTENSION_MIME_DEFAULT);
}
+
#ifdef NX_WEB_HTTP_DIGEST_ENABLE
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _nx_web_http_server_nonce_allocate PORTABLE C */
+/* 6.2.0 */
+/* AUTHOR */
+/* */
+/* Yuxin Zhou, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function allocate a new nonce for digest authentication. */
+/* */
+/* INPUT */
+/* */
+/* server_ptr HTTP Server pointer */
+/* nonce_ptr Allocated nonce pointer */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* tx_time_get Get system time */
+/* */
+/* CALLED BY */
+/* */
+/* _nx_web_http_server_digest_authenticate */
+/* Digest authentication */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 10-31-2022 Yuxin Zhou Initial Version 6.2.0 */
+/* */
+/**************************************************************************/
+UINT _nx_web_http_server_nonce_allocate(NX_WEB_HTTP_SERVER *server_ptr, NX_WEB_HTTP_SERVER_NONCE **nonce_ptr)
+{
+UINT i;
+UCHAR random_value;
+NX_WEB_HTTP_SERVER_NONCE *nonces_list = server_ptr -> nx_web_http_server_nonces;
+
+
+ /* Search if there is free entry for new nonce. */
+ for (i = 0; i < NX_WEB_HTTP_SERVER_NONCE_MAX; i++)
+ {
+ if (nonces_list[i].nonce_state == NX_WEB_HTTP_SERVER_NONCE_INVALID)
+ {
+ *nonce_ptr = &(nonces_list[i]);
+ break;
+ }
+ }
+
+ if (i == NX_WEB_HTTP_SERVER_NONCE_MAX)
+ {
+
+ /* If no free entry, check the timeout of allocated nonces. */
+ for (i = 0; i < NX_WEB_HTTP_SERVER_NONCE_MAX; i++)
+ {
+ if (nonces_list[i].nonce_state == NX_WEB_HTTP_SERVER_NONCE_VALID)
+ {
+ if (tx_time_get() > nonces_list[i].nonce_timestamp + NX_WEB_HTTP_SERVER_NONCE_TIMEOUT)
+ {
+
+ /* If this nonce is timed out, free up this entry for new nonce. */
+ *nonce_ptr = &(nonces_list[i]);
+ break;
+ }
+ }
+ }
+
+ /* If no entry can be allocated, return error. */
+ if (i == NX_WEB_HTTP_SERVER_NONCE_MAX)
+ {
+ return(NX_NOT_FOUND);
+ }
+ }
+
+ /* Generate new nonce for digest authentication. */
+ for (i = 0; i < NX_WEB_HTTP_SERVER_NONCE_SIZE; i++)
+ {
+ random_value = (UCHAR)NX_RAND() % (sizeof(_nx_web_http_server_base64_array) - 1);
+ (*nonce_ptr) -> nonce_buffer[i] = (UCHAR)_nx_web_http_server_base64_array[random_value];
+ }
+
+ /* Reset the timestamp and state for the new nonce. */
+ (*nonce_ptr) -> nonce_timestamp = tx_time_get();
+ (*nonce_ptr) -> nonce_state = NX_WEB_HTTP_SERVER_NONCE_VALID;
+
+ return(NX_SUCCESS);
+}
+
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nx_web_http_server_digest_authenticate PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -6312,6 +6414,9 @@ UINT temp_name_length;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* supported random nonce, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_web_http_server_digest_authenticate(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *name_ptr, CHAR *password_ptr, CHAR *realm_ptr, UINT *auth_request_present)
@@ -6329,6 +6434,7 @@ CHAR crlf[2] = {13,10};
CHAR authorization_nc[NX_WEB_HTTP_MAX_RESOURCE + 1];
CHAR authorization_cnonce[NX_WEB_HTTP_MAX_RESOURCE + 1];
UINT realm_length;
+NX_WEB_HTTP_SERVER_NONCE *nonce_ptr = NX_NULL;
/* Default to no authentication request detected. */
*auth_request_present = NX_FALSE;
@@ -6337,7 +6443,7 @@ UINT realm_length;
status = NX_WEB_HTTP_DIGEST_AUTHENTICATE;
/* Is the authorization request present? */
- if (_nx_web_http_server_retrieve_digest_authorization(packet_ptr, authorization_response, authorization_uri, authorization_nc, authorization_cnonce))
+ if (_nx_web_http_server_retrieve_digest_authorization(server_ptr, packet_ptr, authorization_response, authorization_uri, authorization_nc, authorization_cnonce, &nonce_ptr))
{
/* Yes, an authorization request is present. */
@@ -6371,7 +6477,7 @@ UINT realm_length;
}
/* Calculate what the MD5 should be. */
- _nx_web_http_server_digest_response_calculate(server_ptr, name_ptr, realm_ptr, password_ptr, _nx_web_http_server_nonce, method, authorization_uri, authorization_nc, authorization_cnonce, calculated_response);
+ _nx_web_http_server_digest_response_calculate(server_ptr, name_ptr, realm_ptr, password_ptr, (CHAR *)(nonce_ptr -> nonce_buffer), method, authorization_uri, authorization_nc, authorization_cnonce, calculated_response);
/* Determine if the calculated response is the same as the received response. */
i = 0;
@@ -6389,6 +6495,32 @@ UINT realm_length;
/* Otherwise, look at next character. */
i++;
}
+
+ /* If the response is authenticated, mark the nonce as accepted. */
+ if (status == NX_SUCCESS)
+ {
+
+ /* If another session uses the same nonce, don't accept it. */
+ if (nonce_ptr -> nonce_state == NX_WEB_HTTP_SERVER_NONCE_ACCEPTED)
+ {
+ if (nonce_ptr -> nonce_session_ptr != server_ptr -> nx_web_http_server_current_session_ptr)
+ {
+ status = NX_WEB_HTTP_DIGEST_AUTHENTICATE;
+ }
+ }
+ else
+ {
+
+ /* Update nonce state and set the session pointer for mapping in disconnection. */
+ nonce_ptr -> nonce_state = NX_WEB_HTTP_SERVER_NONCE_ACCEPTED;
+ nonce_ptr -> nonce_session_ptr = server_ptr -> nx_web_http_server_current_session_ptr;
+ }
+ }
+ else
+ {
+ nonce_ptr -> nonce_state = NX_WEB_HTTP_SERVER_NONCE_INVALID;
+ }
+
/* If digest authenticate callback function returns non-success value, the request is
considered unauthenticated. */
if(callback_status != NX_SUCCESS)
@@ -6399,6 +6531,24 @@ UINT realm_length;
if (status == NX_WEB_HTTP_DIGEST_AUTHENTICATE)
{
+ /* Allocate a new nonce for digest authentication. */
+ status1 = _nx_web_http_server_nonce_allocate(server_ptr, &nonce_ptr);
+
+ /* Determine if an error occurred in the packet allocation. */
+ if (status1)
+ {
+
+ /* Send response back to HTTP Client. */
+ _nx_web_http_server_response_send(server_ptr, NX_WEB_HTTP_STATUS_INTERNAL_ERROR, sizeof(NX_WEB_HTTP_STATUS_INTERNAL_ERROR) - 1,
+ "NetX HTTP Server Internal Error", sizeof("NetX HTTP Server Internal Error") - 1, NX_NULL, 0);
+
+ /* Indicate an allocation error occurred. */
+ server_ptr -> nx_web_http_server_allocation_errors++;
+
+ /* Return the internal NetX error. */
+ return(status1);
+ }
+
/* We need authorization so build the HTTP 401 Unauthorized message to send to the server. */
/* Check string length. */
@@ -6481,7 +6631,7 @@ UINT realm_length;
server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
/* Place the nonce string into the buffer. */
- nx_packet_data_append(packet_ptr, _nx_web_http_server_nonce, sizeof(_nx_web_http_server_nonce) - 1,
+ nx_packet_data_append(packet_ptr, nonce_ptr -> nonce_buffer, NX_WEB_HTTP_SERVER_NONCE_SIZE,
server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
/* Insert the double quote. */
@@ -6496,6 +6646,14 @@ UINT realm_length;
nx_packet_data_append(packet_ptr, crlf, 2,
server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
+ /* Set Content-Length as 0. */
+ nx_packet_data_append(packet_ptr, "Content-Length: 0", 17,
+ server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
+
+ /* Place the into the buffer. */
+ nx_packet_data_append(packet_ptr, crlf, 2,
+ server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
+
/* Place another into the buffer to signal end of FULL HTTP response. */
nx_packet_data_append(packet_ptr, crlf, 2,
server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
@@ -6525,7 +6683,7 @@ UINT realm_length;
/* FUNCTION RELEASE */
/* */
/* _nx_web_http_server_digest_response_calculate PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -6572,6 +6730,9 @@ UINT realm_length;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* supported random nonce, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID _nx_web_http_server_digest_response_calculate(NX_WEB_HTTP_SERVER *server_ptr, CHAR *username, CHAR *realm, CHAR *password, CHAR *nonce, CHAR *method, CHAR *uri, CHAR *nc, CHAR *cnonce, CHAR *result)
@@ -6585,7 +6746,6 @@ UINT password_length;
UINT realm_length;
UINT method_length;
UINT uri_length;
-UINT nonce_length;
UINT nc_length;
UINT cnonce_length;
@@ -6595,7 +6755,6 @@ UINT cnonce_length;
_nx_utility_string_length_check(realm, &realm_length, NX_MAX_STRING_LENGTH) ||
_nx_utility_string_length_check(method, &method_length, 7) ||
_nx_utility_string_length_check(uri, &uri_length, NX_WEB_HTTP_MAX_RESOURCE) ||
- _nx_utility_string_length_check(nonce, &nonce_length, sizeof(_nx_web_http_server_nonce) - 1) ||
_nx_utility_string_length_check(nc, &nc_length, NX_WEB_HTTP_MAX_RESOURCE) ||
_nx_utility_string_length_check(cnonce, &cnonce_length, NX_WEB_HTTP_MAX_RESOURCE))
{
@@ -6629,7 +6788,7 @@ UINT cnonce_length;
_nx_md5_initialize(&(server_ptr -> nx_web_http_server_md5data));
_nx_md5_update(&(server_ptr -> nx_web_http_server_md5data), (unsigned char *) ha1_string, sizeof(ha1_string) - 1);
_nx_md5_update(&(server_ptr -> nx_web_http_server_md5data), (unsigned char *) ":", 1);
- _nx_md5_update(&(server_ptr -> nx_web_http_server_md5data), (unsigned char *) nonce, nonce_length);
+ _nx_md5_update(&(server_ptr -> nx_web_http_server_md5data), (unsigned char *) nonce, NX_WEB_HTTP_SERVER_NONCE_SIZE);
/* Start of Internet Explorer bug work-around. */
_nx_md5_update(&(server_ptr -> nx_web_http_server_md5data), (unsigned char *) ":", 1);
@@ -6654,7 +6813,7 @@ UINT cnonce_length;
/* FUNCTION RELEASE */
/* */
/* _nx_web_http_server_retrieve_digest_authorization PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -6666,11 +6825,13 @@ UINT cnonce_length;
/* */
/* INPUT */
/* */
+/* server_ptr HTTP Server pointer */
/* packet_ptr Request packet pointer */
/* response Digest response pointer */
/* uri URI from response pointer */
/* nc Nonce count string */
/* cnonce Client nonce string */
+/* nonce_ptr Server nonce pointer */
/* */
/* OUTPUT */
/* */
@@ -6694,15 +6855,20 @@ UINT cnonce_length;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* supported random nonce, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
-UINT _nx_web_http_server_retrieve_digest_authorization(NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce)
+UINT _nx_web_http_server_retrieve_digest_authorization(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce, NX_WEB_HTTP_SERVER_NONCE **nonce_ptr)
{
UINT length;
UINT found;
CHAR *buffer_ptr;
CHAR *saved_buffer_ptr;
+UCHAR *nonce_buffer;
+UINT i;
/* Set the found flag to false. */
@@ -6822,6 +6988,86 @@ CHAR *saved_buffer_ptr;
/* Save current buffer pointer, so each parameter search always starts from here. */
saved_buffer_ptr = buffer_ptr;
+ while (((buffer_ptr + 6) < (CHAR *) packet_ptr -> nx_packet_append_ptr) && (*buffer_ptr != (CHAR) 0))
+ {
+
+ /* Check for the uri token. */
+ if (((*(buffer_ptr) == 'n') || (*(buffer_ptr) == 'N')) &&
+ ((*(buffer_ptr+1) == 'o') || (*(buffer_ptr+1) == 'O')) &&
+ ((*(buffer_ptr+2) == 'n') || (*(buffer_ptr+2) == 'N')) &&
+ ((*(buffer_ptr+3) == 'c') || (*(buffer_ptr+3) == 'C')) &&
+ ((*(buffer_ptr+4) == 'e') || (*(buffer_ptr+4) == 'E')) &&
+ (*(buffer_ptr+5) == '='))
+ {
+
+ /* Move the pointer up to the actual nonce string. */
+ buffer_ptr = buffer_ptr + 6;
+ found = NX_TRUE;
+
+ break;
+ }
+
+ /* Move the pointer up to the next character. */
+ buffer_ptr++;
+ }
+
+ /* Check if nonce is found. */
+ if (!found)
+ {
+ return(0);
+ }
+
+ /* Now remove any extra blanks and quotes. */
+ while ((buffer_ptr < (CHAR *) packet_ptr -> nx_packet_append_ptr) && ((*buffer_ptr == ' ') || (*buffer_ptr == (CHAR) 0x22)))
+ {
+
+ /* Move the pointer up one character. */
+ buffer_ptr++;
+ }
+
+ /* Now pickup the nonce string. */
+ length = 0;
+ nonce_buffer = (UCHAR *)buffer_ptr;
+ while ((buffer_ptr < (CHAR *) packet_ptr -> nx_packet_append_ptr) && (*buffer_ptr != (CHAR) 0) && (*buffer_ptr != ' ') && (*buffer_ptr != (CHAR) 13))
+ {
+
+ /* Determine if the ending quote is present. */
+ if (*buffer_ptr == (CHAR) 0x22)
+ {
+ break;
+ }
+
+ /* Increase the length. */
+ length++;
+ buffer_ptr++;
+ }
+
+ /* Check the nonce size. */
+ if (length != NX_WEB_HTTP_SERVER_NONCE_SIZE)
+ {
+ return(0);
+ }
+
+ /* Check if the nonce is valid. */
+ for (i = 0; i < NX_WEB_HTTP_SERVER_NONCE_MAX; i++)
+ {
+ if ((server_ptr -> nx_web_http_server_nonces[i].nonce_state != NX_WEB_HTTP_SERVER_NONCE_INVALID) &&
+ (memcmp(server_ptr -> nx_web_http_server_nonces[i].nonce_buffer, nonce_buffer, NX_WEB_HTTP_SERVER_NONCE_SIZE) == 0)) /* Use case of memcmp is verified. */
+ {
+ *nonce_ptr = &(server_ptr -> nx_web_http_server_nonces[i]);
+ break;
+ }
+ }
+
+ /* If the nonca is invalid, just return. */
+ if (i == NX_WEB_HTTP_SERVER_NONCE_MAX)
+ {
+ return(0);
+ }
+
+ /* Get saved buffer pointer. */
+ buffer_ptr = saved_buffer_ptr;
+
/* Now look for the nc in the digest response. */
while (((buffer_ptr+3) < (CHAR *) packet_ptr -> nx_packet_append_ptr) && (*buffer_ptr != (CHAR) 0))
{
@@ -6881,9 +7127,9 @@ CHAR *saved_buffer_ptr;
if (((*buffer_ptr == 'c') || (*buffer_ptr == 'C')) &&
((*(buffer_ptr+1) == 'n') || (*(buffer_ptr+1) == 'N')) &&
((*(buffer_ptr+2) == 'o') || (*(buffer_ptr+2) == 'O')) &&
- ((*(buffer_ptr+3) == 'n') || (*(buffer_ptr+2) == 'N')) &&
- ((*(buffer_ptr+4) == 'c') || (*(buffer_ptr+2) == 'C')) &&
- ((*(buffer_ptr+5) == 'e') || (*(buffer_ptr+2) == 'E')) &&
+ ((*(buffer_ptr+3) == 'n') || (*(buffer_ptr+3) == 'N')) &&
+ ((*(buffer_ptr+4) == 'c') || (*(buffer_ptr+4) == 'C')) &&
+ ((*(buffer_ptr+5) == 'e') || (*(buffer_ptr+5) == 'E')) &&
(*(buffer_ptr+6) == '='))
{
@@ -6988,11 +7234,11 @@ CHAR *saved_buffer_ptr;
if (((*buffer_ptr == 'r') || (*buffer_ptr == 'R')) &&
((*(buffer_ptr+1) == 'e') || (*(buffer_ptr+1) == 'E')) &&
((*(buffer_ptr+2) == 's') || (*(buffer_ptr+2) == 'S')) &&
- ((*(buffer_ptr+3) == 'p') || (*(buffer_ptr+2) == 'P')) &&
- ((*(buffer_ptr+4) == 'o') || (*(buffer_ptr+2) == 'O')) &&
- ((*(buffer_ptr+5) == 'n') || (*(buffer_ptr+2) == 'N')) &&
- ((*(buffer_ptr+6) == 's') || (*(buffer_ptr+2) == 'S')) &&
- ((*(buffer_ptr+7) == 'e') || (*(buffer_ptr+2) == 'E')) &&
+ ((*(buffer_ptr+3) == 'p') || (*(buffer_ptr+3) == 'P')) &&
+ ((*(buffer_ptr+4) == 'o') || (*(buffer_ptr+4) == 'O')) &&
+ ((*(buffer_ptr+5) == 'n') || (*(buffer_ptr+5) == 'N')) &&
+ ((*(buffer_ptr+6) == 's') || (*(buffer_ptr+6) == 'S')) &&
+ ((*(buffer_ptr+7) == 'e') || (*(buffer_ptr+7) == 'E')) &&
(*(buffer_ptr+8) == '='))
{
@@ -10761,7 +11007,7 @@ NX_TCP_SOCKET *tcp_socket;
/* FUNCTION RELEASE */
/* */
/* _nx_web_http_server_connection_disconnect PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -10798,6 +11044,9 @@ NX_TCP_SOCKET *tcp_socket;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* supported random nonce, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
VOID _nx_web_http_server_connection_disconnect(NX_WEB_HTTP_SERVER *server_ptr, NX_TCP_SESSION *session_ptr, UINT wait_option)
@@ -10805,13 +11054,30 @@ VOID _nx_web_http_server_connection_disconnect(NX_WEB_HTTP_SERVER *server_ptr, N
NX_TCP_SOCKET *tcp_socket;
#ifdef NX_WEB_HTTPS_ENABLE
NX_SECURE_TLS_SESSION *tls_session;
-#endif
+#endif /* NX_WEB_HTTPS_ENABLE */
+#ifdef NX_WEB_HTTP_DIGEST_ENABLE
+UINT i;
+#endif /* NX_WEB_HTTP_DIGEST_ENABLE */
#ifndef NX_WEB_HTTPS_ENABLE
NX_PARAMETER_NOT_USED(server_ptr);
NX_PARAMETER_NOT_USED(wait_option);
#endif /* NX_WEB_HTTPS_ENABLE */
+#ifdef NX_WEB_HTTP_DIGEST_ENABLE
+
+ /* Once the nonce has been accepted, set the state as invalid. */
+ for (i = 0; i < NX_WEB_HTTP_SERVER_NONCE_MAX; i++)
+ {
+ if ((server_ptr -> nx_web_http_server_nonces[i].nonce_state == NX_WEB_HTTP_SERVER_NONCE_ACCEPTED) &&
+ (server_ptr -> nx_web_http_server_nonces[i].nonce_session_ptr == session_ptr))
+ {
+ server_ptr -> nx_web_http_server_nonces[i].nonce_state = NX_WEB_HTTP_SERVER_NONCE_INVALID;
+ break;
+ }
+ }
+#endif /* NX_WEB_HTTP_DIGEST_ENABLE */
+
tcp_socket = &(session_ptr -> nx_tcp_session_socket);
#ifdef NX_WEB_HTTPS_ENABLE
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.h
index 12bcbbfc..ae2c0bc4 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.h
@@ -27,7 +27,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* nx_web_http_server.h PORTABLE C */
-/* 6.1.11 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -60,6 +60,9 @@
/* 04-25-2022 Yuxin Zhou Modified comment(s), and */
/* supported ECC configuration,*/
/* resulting in version 6.1.11 */
+/* 10-31-2022 Yuxin Zhou Modified comment(s), and */
+/* supported random nonce, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -175,6 +178,24 @@ extern "C" {
#define NX_WEB_HTTP_SERVER_RETRY_SHIFT 1 /* Every retry is twice as long */
#endif
+#ifndef NX_WEB_HTTP_SERVER_NONCE_MAX
+#define NX_WEB_HTTP_SERVER_NONCE_MAX (NX_WEB_HTTP_SERVER_SESSION_MAX << 1)
+#endif
+
+#ifndef NX_WEB_HTTP_SERVER_NONCE_SIZE
+#define NX_WEB_HTTP_SERVER_NONCE_SIZE 32
+#endif
+
+#ifndef NX_WEB_HTTP_SERVER_NONCE_TIMEOUT
+#define NX_WEB_HTTP_SERVER_NONCE_TIMEOUT (10 * NX_IP_PERIODIC_RATE)
+#endif
+
+/* Define the state of the nonce. */
+
+#define NX_WEB_HTTP_SERVER_NONCE_INVALID 0
+#define NX_WEB_HTTP_SERVER_NONCE_VALID 1
+#define NX_WEB_HTTP_SERVER_NONCE_ACCEPTED 2
+
/* Define HTTP Server request types. */
#define NX_WEB_HTTP_SERVER_UNKNOWN_REQUEST 0
@@ -225,6 +246,16 @@ typedef struct NX_WEB_HTTP_SERVER_DATE_STRUCT
UCHAR nx_web_http_server_weekday; /* Weekday */
} NX_WEB_HTTP_SERVER_DATE;
+/* Define the nonce structure. */
+
+typedef struct NX_WEB_HTTP_SERVER_NONCE_STRUCT
+{
+ UINT nonce_state; /* The state of the nonce */
+ ULONG nonce_timestamp; /* The time when the nonce is created */
+ NX_TCP_SESSION *nonce_session_ptr; /* The session accepted with this nonce */
+ UCHAR nonce_buffer[NX_WEB_HTTP_SERVER_NONCE_SIZE]; /* Nonce for digest authetication */
+} NX_WEB_HTTP_SERVER_NONCE;
+
/* Define the multipart context data structure. */
typedef struct NX_WEB_HTTP_SERVER_MULTIPART_STRUCT
@@ -290,6 +321,9 @@ typedef struct NX_WEB_HTTP_SERVER_STRUCT
#ifdef NX_WEB_HTTP_DIGEST_ENABLE
NX_MD5 nx_web_http_server_md5data; /* HTTP server MD5 work area */
+ NX_WEB_HTTP_SERVER_NONCE
+ nx_web_http_server_nonces[NX_WEB_HTTP_SERVER_NONCE_MAX];
+ /* Nonce for digest authetication */
#endif /* NX_WEB_HTTP_DIGEST_ENABLE */
#ifdef NX_WEB_HTTP_MULTIPART_ENABLE
@@ -566,7 +600,6 @@ UINT _nx_web_http_server_authentication_check_set(NX_WEB_HTTP_SERVER *htt
/* Define internal HTTP Server functions. */
-VOID _nx_web_http_server_connection_present(NX_TCP_SOCKET *socket_ptr, UINT port);
UINT _nx_web_http_server_get_client_request(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET **packet_ptr);
VOID _nx_web_http_server_get_process(NX_WEB_HTTP_SERVER *server_ptr, UINT request_type, NX_PACKET *packet_ptr);
VOID _nx_web_http_server_put_process(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr);
@@ -591,8 +624,9 @@ VOID _nx_web_http_server_connection_disconnect(NX_WEB_HTTP_SERVER *server
#ifdef NX_WEB_HTTP_DIGEST_ENABLE
UINT _nx_web_http_server_digest_authenticate(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *name_ptr, CHAR *password_ptr, CHAR *realm_ptr, UINT *auth_request_present);
VOID _nx_web_http_server_digest_response_calculate(NX_WEB_HTTP_SERVER *server_ptr, CHAR *username, CHAR *realm, CHAR *password, CHAR *nonce, CHAR *method, CHAR *uri, CHAR *nc, CHAR *cnonce, CHAR *result);
-UINT _nx_web_http_server_retrieve_digest_authorization(NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce);
+UINT _nx_web_http_server_retrieve_digest_authorization(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce, NX_WEB_HTTP_SERVER_NONCE **nonce_ptr);
VOID _nx_web_http_server_hex_ascii_convert(CHAR *source, UINT source_length, CHAR *destination);
+UINT _nx_web_http_server_nonce_allocate(NX_WEB_HTTP_SERVER *server_ptr, NX_WEB_HTTP_SERVER_NONCE **nonce_ptr);
#endif
#ifdef NX_WEB_HTTP_MULTIPART_ENABLE
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_const.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_const.h
index b35f6d4c..213bdcd1 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_const.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_const.h
@@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* nx_crypto_const.h PORTABLE C */
-/* 6.1.11 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -50,6 +50,9 @@
/* 04-25-2022 Yuxin Zhou Modified comment(s), added */
/* x25519 and x448 curves, */
/* resulting in version 6.1.11 */
+/* 10-31-2022 Yanwu Cai Modified comment(s), added */
+/* EC curve type macro, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -213,6 +216,11 @@ extern "C" {
#define NX_CRYPTO_EC_POINT_ANSIX962_COMPRESSED_PRIME 1
#define NX_CRYPTO_EC_POINT_ANSIX962_COMPRESSED_CHAR2 2
+/* Elliptic curve type definitions. */
+#define NX_CRYPTO_EC_CURVE_TYPE_EXPLICIT_PRIME 1
+#define NX_CRYPTO_EC_CURVE_TYPE_EXPLICIT_CHAR2 2
+#define NX_CRYPTO_EC_CURVE_TYPE_NAMED_CURVE 3
+
/* Define crypto ICV bits size. */
#define NX_CRYPTO_AUTHENTICATION_ICV_TRUNC_BITS 96
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_ec.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_ec.h
index aea5c89c..0a372cb9 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_ec.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_ec.h
@@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* nx_crypto_ec.h PORTABLE C */
-/* 6.1.11 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -50,6 +50,9 @@
/* 04-25-2022 Yuxin Zhou Modified comment(s), */
/* added x25519 curve, */
/* resulting in version 6.1.11 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* added x448 curve, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@@ -632,12 +635,14 @@ UINT _nx_crypto_method_ec_secp521r1_operation(UINT op,
#ifdef NX_CRYPTO_ENABLE_CURVE25519_448
extern NX_CRYPTO_CONST NX_CRYPTO_EC _nx_crypto_ec_x25519;
+extern NX_CRYPTO_CONST NX_CRYPTO_EC _nx_crypto_ec_x448;
+
VOID _nx_crypto_ec_cswap(UINT swap, NX_CRYPTO_HUGE_NUMBER *h1, NX_CRYPTO_HUGE_NUMBER *h2);
-VOID _nx_crypto_ec_x25519_multiple(NX_CRYPTO_EC *curve,
- NX_CRYPTO_EC_POINT *u,
- NX_CRYPTO_HUGE_NUMBER *k,
- NX_CRYPTO_EC_POINT *r,
- HN_UBASE *scratch);
+VOID _nx_crypto_ec_x25519_448_multiple(NX_CRYPTO_EC *curve,
+ NX_CRYPTO_EC_POINT *u,
+ NX_CRYPTO_HUGE_NUMBER *k,
+ NX_CRYPTO_EC_POINT *r,
+ HN_UBASE *scratch);
UINT _nx_crypto_method_ec_x25519_operation(UINT op,
VOID *handle,
struct NX_CRYPTO_METHOD_STRUCT *method,
@@ -648,11 +653,21 @@ UINT _nx_crypto_method_ec_x25519_operation(UINT op,
VOID *crypto_metadata, ULONG crypto_metadata_size,
VOID *packet_ptr,
VOID (*nx_crypto_hw_process_callback)(VOID *, UINT));
-UINT _nx_crypto_ec_key_pair_generation_x25519(NX_CRYPTO_EC *curve,
- NX_CRYPTO_EC_POINT *g,
- NX_CRYPTO_HUGE_NUMBER *private_key,
- NX_CRYPTO_EC_POINT *public_key,
- HN_UBASE *scratch);
+UINT _nx_crypto_method_ec_x448_operation(UINT op,
+ VOID *handle,
+ struct NX_CRYPTO_METHOD_STRUCT *method,
+ UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits,
+ UCHAR *input, ULONG input_length_in_byte,
+ UCHAR *iv_ptr,
+ UCHAR *output, ULONG output_length_in_byte,
+ VOID *crypto_metadata, ULONG crypto_metadata_size,
+ VOID *packet_ptr,
+ VOID (*nx_crypto_hw_process_callback)(VOID *, UINT));
+UINT _nx_crypto_ec_key_pair_generation_x25519_448(NX_CRYPTO_EC *curve,
+ NX_CRYPTO_EC_POINT *g,
+ NX_CRYPTO_HUGE_NUMBER *private_key,
+ NX_CRYPTO_EC_POINT *public_key,
+ HN_UBASE *scratch);
UINT _nx_crypto_ec_extract_fixed_size_le(NX_CRYPTO_HUGE_NUMBER *number,
UCHAR *byte_stream, UINT byte_stream_size);
#endif /* NX_CRYPTO_ENABLE_CURVE25519_448 */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_aes.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_aes.c
index 371022e3..16b4ae9f 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_aes.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_aes.c
@@ -2167,7 +2167,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_crypto_method_aes_ccm_operation PORTABLE C */
-/* 6.1 */
+/* 6.x */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -2215,6 +2215,9 @@ UINT status;
/* 05-19-2020 Timothy Stapko Initial Version 6.0 */
/* 09-30-2020 Timothy Stapko Modified comment(s), */
/* resulting in version 6.1 */
+/* xx-xx-xxxx Tiejun Zhou Modified comment(s), and */
+/* fixed compiler warnings, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
NX_CRYPTO_KEEP UINT _nx_crypto_method_aes_ccm_operation(UINT op, /* Encrypt, Decrypt, Authenticate */
@@ -2278,7 +2281,7 @@ UINT status;
break;
}
- if (input_length_in_byte < (method -> nx_crypto_ICV_size_in_bits >> 3) ||
+ if (input_length_in_byte < (ULONG)(method -> nx_crypto_ICV_size_in_bits >> 3) ||
output_length_in_byte < input_length_in_byte - (method -> nx_crypto_ICV_size_in_bits >> 3))
{
status = NX_CRYPTO_INVALID_BUFFER_SIZE;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ec.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ec.c
index cdd90127..530b777e 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ec.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ec.c
@@ -4402,6 +4402,36 @@ static NX_CRYPTO_CONST HN_UBASE _nx_crypto_ec_x25519_h[] =
HN_ULONG_TO_UBASE(0x00000008)
};
+/* x448 */
+static NX_CRYPTO_CONST HN_UBASE _nx_crypto_ec_x448_p[] =
+{
+
+ /* p = ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff */
+ HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFF),
+ HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFF),
+ HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFF),
+ HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFE),
+ HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFF),
+ HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFF),
+ HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFF),
+};
+
+static NX_CRYPTO_CONST HN_UBASE _nx_crypto_ec_x448_gx[] =
+{
+
+ /* U(P) = 5 */
+ HN_ULONG_TO_UBASE(0x00000005)
+};
+
+
+static NX_CRYPTO_CONST HN_UBASE _nx_crypto_ec_x448_h[] =
+{
+
+ /* h = 04 */
+ HN_ULONG_TO_UBASE(0x00000004)
+};
+
+
NX_CRYPTO_CONST NX_CRYPTO_EC _nx_crypto_ec_x25519 =
{
"x25519",
@@ -4440,23 +4470,67 @@ NX_CRYPTO_CONST NX_CRYPTO_EC _nx_crypto_ec_x25519 =
(NX_CRYPTO_EC_FIXED_POINTS *)NX_CRYPTO_NULL,
NX_CRYPTO_NULL,
NX_CRYPTO_NULL,
- _nx_crypto_ec_x25519_multiple,
+ _nx_crypto_ec_x25519_448_multiple,
+ NX_CRYPTO_NULL
+};
+
+NX_CRYPTO_CONST NX_CRYPTO_EC _nx_crypto_ec_x448 =
+{
+ "x448",
+ NX_CRYPTO_EC_X448,
+ 5,
+ 448,
+ {
+ .fp =
+ {
+ (HN_UBASE *)_nx_crypto_ec_x448_p,
+ sizeof(_nx_crypto_ec_x448_p) >> HN_SIZE_SHIFT,
+ sizeof(_nx_crypto_ec_x448_p),
+ (UINT)NX_CRYPTO_FALSE
+ }
+ },
+ {(HN_UBASE *)NX_CRYPTO_NULL, 0u, 0u, 0u},
+ {(HN_UBASE *)NX_CRYPTO_NULL, 0u, 0u, 0u},
+ {
+ NX_CRYPTO_EC_POINT_AFFINE,
+ {
+ (HN_UBASE *)_nx_crypto_ec_x448_gx,
+ sizeof(_nx_crypto_ec_x448_gx) >> HN_SIZE_SHIFT,
+ sizeof(_nx_crypto_ec_x448_gx),
+ (UINT)NX_CRYPTO_FALSE
+ },
+ {(HN_UBASE *)NX_CRYPTO_NULL, 0u, 0u, 0u},
+ {(HN_UBASE *)NX_CRYPTO_NULL, 0u, 0u, 0u}
+ },
+ {(HN_UBASE *)NX_CRYPTO_NULL, 0u, 0u, 0u},
+ {
+ (HN_UBASE *)_nx_crypto_ec_x448_h,
+ sizeof(_nx_crypto_ec_x448_h) >> HN_SIZE_SHIFT,
+ sizeof(_nx_crypto_ec_x448_h),
+ (UINT)NX_CRYPTO_FALSE
+ },
+ (NX_CRYPTO_EC_FIXED_POINTS *)NX_CRYPTO_NULL,
+ NX_CRYPTO_NULL,
+ NX_CRYPTO_NULL,
+ _nx_crypto_ec_x25519_448_multiple,
NX_CRYPTO_NULL
};
+
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
-/* _nx_crypto_ec_x25519_multiple PORTABLE C */
-/* 6.1.11 */
+/* _nx_crypto_ec_x25519_448_multiple PORTABLE C */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
-/* This function performs the scalar multiplication on X25519 curve. */
+/* This function performs the scalar multiplication on X25519 and X448 */
+/* curves. */
/* */
/* INPUT */
/* */
@@ -4494,13 +4568,16 @@ NX_CRYPTO_CONST NX_CRYPTO_EC _nx_crypto_ec_x25519 =
/* DATE NAME DESCRIPTION */
/* */
/* 04-25-2022 Yuxin Zhou Initial Version 6.1.11 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* added x448 curve, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
-NX_CRYPTO_KEEP VOID _nx_crypto_ec_x25519_multiple(NX_CRYPTO_EC* curve,
- NX_CRYPTO_EC_POINT* u,
- NX_CRYPTO_HUGE_NUMBER* k,
- NX_CRYPTO_EC_POINT* r,
- HN_UBASE* scratch)
+NX_CRYPTO_KEEP VOID _nx_crypto_ec_x25519_448_multiple(NX_CRYPTO_EC* curve,
+ NX_CRYPTO_EC_POINT* u,
+ NX_CRYPTO_HUGE_NUMBER* k,
+ NX_CRYPTO_EC_POINT* r,
+ HN_UBASE* scratch)
{
NX_CRYPTO_HUGE_NUMBER k_2;
NX_CRYPTO_HUGE_NUMBER x_1;
@@ -4513,33 +4590,55 @@ NX_CRYPTO_HUGE_NUMBER t_2;
INT t;
UINT k_t;
UINT swap;
+UINT clen;
+ULONG a24;
HN_UBASE* k_buf;
+ clen = (curve -> nx_crypto_ec_bits + 7) >> 3;
- NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&k_2, scratch, 32);
- NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&x_1, scratch, 32);
- NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&x_2, scratch, 64);
- NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&z_2, scratch, 64);
- NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&x_3, scratch, 64);
- NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&z_3, scratch, 64);
- NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&t_1, scratch, 64);
- NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&t_2, scratch, 64);
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&k_2, scratch, clen);
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&x_1, scratch, clen);
+ clen = clen << 1;
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&x_2, scratch, clen);
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&z_2, scratch, clen);
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&x_3, scratch, clen);
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&z_3, scratch, clen);
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&t_1, scratch, clen);
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&t_2, scratch, clen);
NX_CRYPTO_HUGE_NUMBER_COPY(&k_2, k);
NX_CRYPTO_HUGE_NUMBER_COPY(&x_1, &u -> nx_crypto_ec_point_x);
- x_1.nx_crypto_huge_number_data[7] &= 0x7FFFFFFF;
+
+ if (curve -> nx_crypto_ec_id == NX_CRYPTO_EC_X25519)
+ {
+ /* x25519 */
+ x_1.nx_crypto_huge_number_data[7] &= 0x7FFFFFFF;
+
+ k_buf = k_2.nx_crypto_huge_number_data;
+
+ k_buf[0] &= 0xFFFFFFF8;
+ k_buf[7] &= 0x7FFFFFFF;
+ k_buf[7] |= 0x40000000;
+ a24 = 121665;
+ }
+ else
+ {
+ /* x448 */
+
+ k_buf = k_2.nx_crypto_huge_number_data;
+
+ k_buf[0] &= 0xFFFFFFFC;
+ k_buf[13] |= 0x80000000;
+ a24 = 39081;
+ }
+
NX_CRYPTO_HUGE_NUMBER_SET_DIGIT(&x_2, 1);
NX_CRYPTO_HUGE_NUMBER_COPY(&x_3, &x_1);
NX_CRYPTO_HUGE_NUMBER_SET_DIGIT(&z_3, 1);
- k_buf = k_2.nx_crypto_huge_number_data;
-
- k_buf[0] &= 0xFFFFFFF8;
- k_buf[7] &= 0x7FFFFFFF;
- k_buf[7] |= 0x40000000;
swap = 0;
- for (t = 254; t >= 0; t--)
+ for (t = (INT)(curve -> nx_crypto_ec_bits - 1); t >= 0; t--)
{
k_t = 1 & (k_buf[t >> 5] >> (t & 31));
swap ^= k_t;
@@ -4550,6 +4649,7 @@ HN_UBASE* k_buf;
/* A = x_2 + z_2 */
NX_CRYPTO_HUGE_NUMBER_COPY(&t_1, &x_2);
_nx_crypto_huge_number_add(&t_1, &z_2);
+ _nx_crypto_huge_number_modulus(&t_1, &curve->nx_crypto_ec_field.fp);
/* B = x_2 - z_2 */
_nx_crypto_huge_number_subtract(&x_2, &z_2);
@@ -4572,6 +4672,7 @@ HN_UBASE* k_buf;
/* t_2 = DA + CB */
NX_CRYPTO_HUGE_NUMBER_COPY(&t_2, &z_2);
_nx_crypto_huge_number_add(&t_2, &z_3);
+ _nx_crypto_huge_number_modulus(&t_2, &curve->nx_crypto_ec_field.fp);
/* z_3 = DA - CB */
_nx_crypto_huge_number_subtract(&z_3, &z_2);
@@ -4605,7 +4706,7 @@ HN_UBASE* k_buf;
_nx_crypto_huge_number_modulus(&x_2, &curve -> nx_crypto_ec_field.fp);
/* z_2 = E * (AA + a24 * E) */
- _nx_crypto_huge_number_multiply_digit(&t_2, 121665, &t_1);
+ _nx_crypto_huge_number_multiply_digit(&t_2, a24, &t_1);
_nx_crypto_huge_number_add(&t_1, &z_2);
_nx_crypto_huge_number_modulus(&t_1, &curve -> nx_crypto_ec_field.fp);
@@ -4656,7 +4757,7 @@ HN_UBASE* k_buf;
/* */
/* CALLED BY */
/* */
-/* _nx_crypto_ec_x25519_multiple Scalar multiplication */
+/* _nx_crypto_ec_x25519_448_multiple Scalar multiplication */
/* */
/* RELEASE HISTORY */
/* */
@@ -4779,8 +4880,93 @@ NX_CRYPTO_KEEP UINT _nx_crypto_method_ec_x25519_operation(UINT op,
/* */
/* FUNCTION RELEASE */
/* */
-/* _nx_crypto_ec_key_pair_generation_x25519 PORTABLE C */
-/* 6.1.11 */
+/* _nx_crypto_method_ec_x448_operation PORTABLE C */
+/* 6.1.12 */
+/* AUTHOR */
+/* */
+/* Yuxin Zhou, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function returns the x448 curve. */
+/* */
+/* INPUT */
+/* */
+/* op Operation */
+/* handle Crypto handle */
+/* method Cryption Method Object */
+/* key Encryption Key */
+/* key_size_in_bits Key size in bits */
+/* input Input data */
+/* input_length_in_byte Input data size */
+/* iv_ptr Initial vector */
+/* output Output buffer */
+/* output_length_in_byte Output buffer size */
+/* crypto_metadata Metadata area */
+/* crypto_metadata_size Metadata area size */
+/* packet_ptr Pointer to packet */
+/* nx_crypto_hw_process_callback Callback function pointer */
+/* */
+/* OUTPUT */
+/* */
+/* status Completion status */
+/* */
+/* CALLS */
+/* */
+/* None */
+/* */
+/* CALLED BY */
+/* */
+/* Application Code */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 07-29-2022 Yuxin Zhou Initial Version 6.1.12 */
+/* */
+/**************************************************************************/
+NX_CRYPTO_KEEP UINT _nx_crypto_method_ec_x448_operation(UINT op,
+ VOID *handle,
+ struct NX_CRYPTO_METHOD_STRUCT *method,
+ UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits,
+ UCHAR *input, ULONG input_length_in_byte,
+ UCHAR *iv_ptr,
+ UCHAR *output, ULONG output_length_in_byte,
+ VOID *crypto_metadata, ULONG crypto_metadata_size,
+ VOID *packet_ptr,
+ VOID (*nx_crypto_hw_process_callback)(VOID *, UINT))
+{
+ NX_CRYPTO_PARAMETER_NOT_USED(handle);
+ NX_CRYPTO_PARAMETER_NOT_USED(method);
+ NX_CRYPTO_PARAMETER_NOT_USED(key);
+ NX_CRYPTO_PARAMETER_NOT_USED(key_size_in_bits);
+ NX_CRYPTO_PARAMETER_NOT_USED(input);
+ NX_CRYPTO_PARAMETER_NOT_USED(input_length_in_byte);
+ NX_CRYPTO_PARAMETER_NOT_USED(iv_ptr);
+ NX_CRYPTO_PARAMETER_NOT_USED(output);
+ NX_CRYPTO_PARAMETER_NOT_USED(output_length_in_byte);
+ NX_CRYPTO_PARAMETER_NOT_USED(crypto_metadata);
+ NX_CRYPTO_PARAMETER_NOT_USED(crypto_metadata_size);
+ NX_CRYPTO_PARAMETER_NOT_USED(packet_ptr);
+ NX_CRYPTO_PARAMETER_NOT_USED(nx_crypto_hw_process_callback);
+
+ if (op != NX_CRYPTO_EC_CURVE_GET)
+ {
+ return(NX_CRYPTO_NOT_SUCCESSFUL);
+ }
+
+ *((NX_CRYPTO_EC **)output) = (NX_CRYPTO_EC *)&_nx_crypto_ec_x448;
+
+ return(NX_CRYPTO_SUCCESS);
+}
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _nx_crypto_ec_key_pair_generation_x25519_448 PORTABLE C */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -4815,13 +5001,16 @@ NX_CRYPTO_KEEP UINT _nx_crypto_method_ec_x25519_operation(UINT op,
/* DATE NAME DESCRIPTION */
/* */
/* 04-25-2022 Yuxin Zhou Initial Version 6.1.11 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* added x448 curve, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
-NX_CRYPTO_KEEP UINT _nx_crypto_ec_key_pair_generation_x25519(NX_CRYPTO_EC *curve,
- NX_CRYPTO_EC_POINT *g,
- NX_CRYPTO_HUGE_NUMBER *private_key,
- NX_CRYPTO_EC_POINT *public_key,
- HN_UBASE *scratch)
+NX_CRYPTO_KEEP UINT _nx_crypto_ec_key_pair_generation_x25519_448(NX_CRYPTO_EC *curve,
+ NX_CRYPTO_EC_POINT *g,
+ NX_CRYPTO_HUGE_NUMBER *private_key,
+ NX_CRYPTO_EC_POINT *public_key,
+ HN_UBASE *scratch)
{
UINT status;
UINT buffer_size = (curve -> nx_crypto_ec_bits + 7) >> 3;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ecdh.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ecdh.c
index 38ccdef6..36826cde 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ecdh.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ecdh.c
@@ -968,7 +968,7 @@ NX_CRYPTO_EC *curve;
/* FUNCTION RELEASE */
/* */
/* _nx_crypto_ecdh_setup_x25519_448 PORTABLE C */
-/* 6.1.11 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -1012,6 +1012,9 @@ NX_CRYPTO_EC *curve;
/* DATE NAME DESCRIPTION */
/* */
/* 04-25-2022 Yuxin Zhou Initial Version 6.1.11 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* added x448 curve, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
NX_CRYPTO_KEEP UINT _nx_crypto_ecdh_setup_x25519_448(NX_CRYPTO_ECDH *ecdh_ptr,
@@ -1051,8 +1054,8 @@ NX_CRYPTO_EC_POINT public_key;
sizeof(ecdh_ptr -> nx_crypto_ecdh_private_key_buffer));
/* Generate Key Pair. */
- status = _nx_crypto_ec_key_pair_generation_x25519(curve, &curve -> nx_crypto_ec_g, &private_key,
- &public_key, scratch_buf_ptr);
+ status = _nx_crypto_ec_key_pair_generation_x25519_448(curve, &curve -> nx_crypto_ec_g, &private_key,
+ &public_key, scratch_buf_ptr);
if (status)
{
return(status);
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_generic_ciphersuites.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_generic_ciphersuites.c
index b253ce8e..730c0dfb 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_generic_ciphersuites.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_generic_ciphersuites.c
@@ -29,7 +29,7 @@
/* FUNCTION RELEASE */
/* */
/* nx_crypto_generic_ciphersuites PORTABLE C */
-/* 6.1.11 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -69,6 +69,11 @@
/* 04-25-2022 Yuxin Zhou Modified comment(s), added */
/* x25519 and x448 curves, */
/* resulting in version 6.1.11 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* added x448 curves, */
+/* resulting in version 6.1.12 */
+/* 10-31-2022 Yanwu Cai Modified comment(s), */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -94,6 +99,7 @@ extern NX_CRYPTO_METHOD crypto_method_ec_secp256;
extern NX_CRYPTO_METHOD crypto_method_ec_secp384;
extern NX_CRYPTO_METHOD crypto_method_ec_secp521;
extern NX_CRYPTO_METHOD crypto_method_ec_x25519;
+extern NX_CRYPTO_METHOD crypto_method_ec_x448;
extern NX_CRYPTO_METHOD crypto_method_md5;
extern NX_CRYPTO_METHOD crypto_method_sha1;
extern NX_CRYPTO_METHOD crypto_method_sha224;
@@ -111,6 +117,7 @@ extern NX_CRYPTO_METHOD crypto_method_hmac;
/* Ciphersuite table without ECC. */
/* Lookup table used to map ciphersuites to cryptographic routines. */
+/* For TLS Web servers, define NX_SECURE_ENABLE_AEAD_CIPHER to allow web browsers to connect using AES_128_GCM cipher suites. */
NX_SECURE_TLS_CIPHERSUITE_INFO _nx_crypto_ciphersuite_lookup_table[] =
{
/* Ciphersuite, public cipher, public_auth, session cipher & cipher mode, iv size, key size, hash method, hash size, TLS PRF */
@@ -214,6 +221,7 @@ const UINT _nx_crypto_ciphersuite_lookup_table_tls_1_3_size = sizeof(_nx_crypto_
/* Ciphersuite table with ECC. */
/* Lookup table used to map ciphersuites to cryptographic routines. */
/* Ciphersuites are negotiated IN ORDER - top priority first. Ciphersuites lower in the list are considered less secure. */
+/* For TLS Web servers, define NX_SECURE_ENABLE_AEAD_CIPHER to allow web browsers to connect using AES_128_GCM cipher suites. */
NX_SECURE_TLS_CIPHERSUITE_INFO _nx_crypto_ciphersuite_lookup_table_ecc[] =
{
/* Ciphersuite, public cipher, public_auth, session cipher & cipher mode, iv size, key size, hash method, hash size, TLS PRF */
@@ -290,6 +298,7 @@ const USHORT nx_crypto_ecc_supported_groups[] =
(USHORT)NX_CRYPTO_EC_SECP256R1,
#ifdef NX_CRYPTO_ENABLE_CURVE25519_448
(USHORT)NX_CRYPTO_EC_X25519,
+ (USHORT)NX_CRYPTO_EC_X448,
#endif /* NX_CRYPTO_ENABLE_CURVE25519_448 */
(USHORT)NX_CRYPTO_EC_SECP384R1,
(USHORT)NX_CRYPTO_EC_SECP521R1,
@@ -300,6 +309,7 @@ const NX_CRYPTO_METHOD *nx_crypto_ecc_curves[] =
&crypto_method_ec_secp256,
#ifdef NX_CRYPTO_ENABLE_CURVE25519_448
&crypto_method_ec_x25519,
+ &crypto_method_ec_x448,
#endif /* NX_CRYPTO_ENABLE_CURVE25519_448 */
&crypto_method_ec_secp384,
&crypto_method_ec_secp521,
@@ -610,6 +620,7 @@ const NX_CRYPTO_METHOD *supported_crypto[] =
&crypto_method_ec_secp256,
#ifdef NX_CRYPTO_ENABLE_CURVE25519_448
&crypto_method_ec_x25519,
+ &crypto_method_ec_x448,
#endif /* NX_CRYPTO_ENABLE_CURVE25519_448 */
&crypto_method_ec_secp384,
&crypto_method_ec_secp521,
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_methods.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_methods.c
index 0aa7dc79..bd3731ad 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_methods.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_methods.c
@@ -51,7 +51,7 @@
/* FUNCTION RELEASE */
/* */
/* nx_crypto_methods PORTABLE C */
-/* 6.1.11 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -91,6 +91,9 @@
/* obsolete DES/3DES, */
/* added x25519 curve, */
/* resulting in version 6.1.11 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* added x448 curve, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@@ -533,6 +536,21 @@ NX_CRYPTO_METHOD crypto_method_ec_x25519 =
NX_CRYPTO_NULL, /* Cleanup routine, not used. */
_nx_crypto_method_ec_x25519_operation, /* Operation */
};
+
+/* Declare a placeholder for EC x448. */
+NX_CRYPTO_METHOD crypto_method_ec_x448 =
+{
+ NX_CRYPTO_EC_X448, /* EC placeholder */
+ 448, /* Key size in bits */
+ 0, /* IV size in bits */
+ 0, /* ICV size in bits, not used. */
+ 0, /* Block size in bytes. */
+ 0, /* Metadata size in bytes */
+ NX_CRYPTO_NULL, /* Initialization routine. */
+ NX_CRYPTO_NULL, /* Cleanup routine, not used. */
+ _nx_crypto_method_ec_x448_operation, /* Operation */
+};
+
#endif /* NX_CRYPTO_ENABLE_CURVE25519_448 */
/* Declare the public NULL cipher (not to be confused with the NULL methods above). This
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls.h
index 858267de..419690bd 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls.h
@@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* nx_secure_tls.h PORTABLE C */
-/* 6.1.11 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -85,6 +85,22 @@
/* 04-25-2022 Yuxin Zhou Modified comment(s), and */
/* enabled AEAD for TLS 1.3, */
/* resulting in version 6.1.11 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* updated product constants, */
+/* fixed compiler errors when */
+/* TX_SAFETY_CRITICAL is */
+/* enabled, increased default */
+/* pre-master sec size for PSK,*/
+/* updated alert message for */
+/* downgrade protection, */
+/* resulting in version 6.1.12 */
+/* 10-31-2022 Yanwu Cai Modified comment(s), and added*/
+/* custom secret generation, */
+/* fixed renegotiation when */
+/* receiving in non-block mode,*/
+/* added function to set packet*/
+/* pool, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -105,11 +121,14 @@ extern "C" {
#endif
/* Include the ThreadX and port-specific data type file. */
+#include "tx_port.h"
#ifdef NX_SECURE_SOURCE_CODE
+#ifndef TX_SAFETY_CRITICAL
#ifndef TX_DISABLE_ERROR_CHECKING
#define TX_DISABLE_ERROR_CHECKING
#endif
+#endif
#ifndef NX_DISABLE_ERROR_CHECKING
#define NX_DISABLE_ERROR_CHECKING
#endif
@@ -144,8 +163,8 @@ extern "C" {
#define AZURE_RTOS_NETX_SECURE
#define NETX_SECURE_MAJOR_VERSION 6
-#define NETX_SECURE_MINOR_VERSION 1
-#define NETX_SECURE_PATCH_VERSION 11
+#define NETX_SECURE_MINOR_VERSION 2
+#define NETX_SECURE_PATCH_VERSION 0
/* The following symbols are defined for backward compatibility reasons. */
#define EL_PRODUCT_NETX_SECURE
@@ -289,6 +308,7 @@ extern "C" {
#define NX_SECURE_TLS_RECORD_OVERFLOW 0x151 /* Received a TLSCiphertext record that had a length too long. */
#define NX_SECURE_TLS_HANDSHAKE_FRAGMENT_RECEIVED 0x152 /* Received a fragmented handshake message - take appropriate action at a higher level of the state machine. */
#define NX_SECURE_TLS_TRANSMIT_LOCKED 0x153 /* Another thread is transmitting. */
+#define NX_SECURE_TLS_DOWNGRADE_DETECTED 0x154 /* Detected an inappropriate TLS version downgrade by TLS 1.3 client. */
/* NX_CONTINUE is a symbol defined in NetX Duo 5.10. For backward compatibility, this symbol is defined here */
#if ((__NETXDUO_MAJOR_VERSION__ == 5) && (__NETXDUO_MINOR_VERSION__ == 9))
@@ -648,17 +668,11 @@ typedef struct NX_SECURE_VERSIONS_LIST_STRUCT
#define NX_SECURE_TLS_TRANSCRIPT_IDX_CLIENT_FINISHED (3)
#define NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED (4)
-#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE
-#ifndef NX_SECURE_TLS_PREMASTER_SIZE
-#define NX_SECURE_TLS_PREMASTER_SIZE (68) /* The pre-master secret should be at least 66 bytes for ECDH/ECDHE with secp521r1. */
-#endif
-#else /* !NX_SECURE_ENABLE_ECC_CIPHERSUITE */
-#ifndef NX_SECURE_TLS_PREMASTER_SIZE
-#define NX_SECURE_TLS_PREMASTER_SIZE (48) /* The pre-master secret is 48 bytes, except for PSK ciphersuites for which it may be more. */
-#endif
-#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */
#define NX_SECURE_TLS_RSA_PREMASTER_SIZE (48) /* The size of RSA encrypted pre-master secret. */
+#define NX_SECURE_TLS_EC_PREMASTER_SIZE (68) /* The size of pre-master secret for EC. */
+#ifndef NX_SECURE_TLS_MASTER_SIZE
#define NX_SECURE_TLS_MASTER_SIZE (48) /* The master secret is also 48 bytes. */
+#endif
#define NX_SECURE_TLS_MAX_KEY_SIZE (32) /* Maximum size of a session key in bytes. */
#define NX_SECURE_TLS_MAX_IV_SIZE (16) /* Maximum size of a session initialization vector in bytes. */
#define NX_SECURE_TLS_SESSION_ID_SIZE (256) /* Maximum size of a session ID value used for renegotiation in bytes. */
@@ -699,7 +713,9 @@ typedef struct NX_SECURE_VERSIONS_LIST_STRUCT
* get the actual key values. We need to size the key material according to the maximum amount of
* key material needed by any of the supported ciphersuites, times 2 because there are separate keys for
* client and server. */
+#ifndef NX_SECURE_TLS_KEY_MATERIAL_SIZE
#define NX_SECURE_TLS_KEY_MATERIAL_SIZE (2 * (NX_SECURE_TLS_MAX_HASH_SIZE + NX_SECURE_TLS_MAX_KEY_SIZE + NX_SECURE_TLS_MAX_IV_SIZE))
+#endif
/* PSK-specific defines. If PSK is disabled, don't bring PSK types into the build. */
#if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) || (NX_SECURE_TLS_TLS_1_3_ENABLED)
@@ -722,6 +738,9 @@ typedef struct NX_SECURE_VERSIONS_LIST_STRUCT
#define NX_SECURE_TLS_MAX_PSK_NONCE_SIZE (255)
#endif
+/* The pre-master secret size should be at least (2 * NX_SECURE_TLS_MAX_PSK_SIZE + 4) bytes for PSK cipher suites. */
+#define NX_SECURE_TLS_MIN_PREMASTER_SIZE_PSK (2 * NX_SECURE_TLS_MAX_PSK_SIZE + 4)
+
/* This structure holds the data for Pre-Shared Keys (PSKs) for use with
the TLS PSK ciphersuites. The actual keys are generated from this data
as part of the TLS handshake, but the user must provide this seed and
@@ -777,6 +796,28 @@ typedef struct NX_SECURE_TLS_PSK_STORE_STRUCT
#endif /* defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) */
+#ifndef NX_SECURE_TLS_PREMASTER_SIZE
+
+#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE
+#define NX_SECURE_TLS_MIN_PREMASTER_SIZE NX_SECURE_TLS_EC_PREMASTER_SIZE /* The pre-master secret should be at least 66 bytes for ECDH/ECDHE with secp521r1. */
+#else
+#define NX_SECURE_TLS_MIN_PREMASTER_SIZE NX_SECURE_TLS_RSA_PREMASTER_SIZE /* The pre-master secret should be at least 48 bytes. */
+#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */
+
+#if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE)
+
+#if NX_SECURE_TLS_MIN_PREMASTER_SIZE_PSK > NX_SECURE_TLS_MIN_PREMASTER_SIZE
+#define NX_SECURE_TLS_PREMASTER_SIZE NX_SECURE_TLS_MIN_PREMASTER_SIZE_PSK /* The pre-master secret should be at least NX_SECURE_TLS_MIN_PREMASTER_SIZE_PSK bytes for PSK cipher suites. */
+#else
+#define NX_SECURE_TLS_PREMASTER_SIZE NX_SECURE_TLS_MIN_PREMASTER_SIZE
+#endif
+
+#else
+#define NX_SECURE_TLS_PREMASTER_SIZE NX_SECURE_TLS_MIN_PREMASTER_SIZE
+#endif /* defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) || (NX_SECURE_TLS_TLS_1_3_ENABLED) */
+
+#endif
+
/* TLS Ciphersuite lookup table. Contains all pertinent information for ciphersuites used in TLS operations.
* The lookup is based on the first field, which will contain the defined TLS value for the ciphersuite. */
typedef struct NX_SECURE_TLS_CIPHERSUITE_INFO_STRUCT
@@ -834,13 +875,13 @@ typedef struct NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA_STRUCT
USHORT nx_secure_tls_ecdhe_private_key_length;
/* Private key for ECDHE. */
- UCHAR nx_secure_tls_ecdhe_private_key[NX_SECURE_TLS_PREMASTER_SIZE];
+ UCHAR nx_secure_tls_ecdhe_private_key[NX_SECURE_TLS_EC_PREMASTER_SIZE];
/* Length of the public key. */
USHORT nx_secure_tls_ecdhe_public_key_length;
/* Public key for ECDHE. */
- UCHAR nx_secure_tls_ecdhe_public_key[4 * NX_SECURE_TLS_PREMASTER_SIZE];
+ UCHAR nx_secure_tls_ecdhe_public_key[4 * NX_SECURE_TLS_EC_PREMASTER_SIZE];
} NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA;
@@ -1232,6 +1273,9 @@ typedef struct NX_SECURE_TLS_SESSION_STRUCT
/* Flag to enable/disable session renegotiation at application's choosing. */
USHORT nx_secure_tls_renegotation_enabled;
+
+ /* Flag to indicate that the local host initiated the renegotiation. */
+ USHORT nx_secure_tls_local_initiated_renegotiation;
#endif /* NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION */
#ifndef NX_SECURE_TLS_SERVER_DISABLED
@@ -1339,6 +1383,54 @@ typedef struct NX_SECURE_TLS_SESSION_STRUCT
UINT nx_secure_tls_signature_algorithm;
#endif
+
+ /* Functions that can be replaced to implement custom key generation. */
+ UINT (*nx_secure_generate_premaster_secret)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material,
+ NX_SECURE_TLS_CREDENTIALS *tls_credentials, UINT session_type, USHORT *received_remote_credentials,
+ VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, VOID *tls_ecc_curves);
+ UINT (*nx_secure_generate_master_secret)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version,
+ const NX_CRYPTO_METHOD *session_prf_method, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material,
+ UCHAR *pre_master_sec, UINT pre_master_sec_size, UCHAR *master_sec,
+ VOID *prf_metadata, ULONG prf_metadata_size);
+ UINT (*nx_secure_generate_session_keys)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version,
+ const NX_CRYPTO_METHOD *session_prf_method, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material,
+ UCHAR *master_sec, VOID *prf_metadata, ULONG prf_metadata_size);
+ UINT (*nx_secure_session_keys_set)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material,
+ UINT key_material_data_size, UINT is_client, UCHAR *session_cipher_initialized,
+ VOID *session_cipher_metadata, VOID **session_cipher_handler, ULONG session_cipher_metadata_size);
+#ifndef NX_SECURE_TLS_CLIENT_DISABLED
+ UINT(*nx_secure_process_server_key_exchange)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, NX_SECURE_TLS_CRYPTO *tls_crypto_table,
+ USHORT protocol_version, UCHAR *packet_buffer, UINT message_length,
+ NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials,
+ NX_SECURE_TLS_HANDSHAKE_HASH *tls_handshake_hash,
+ VOID *public_cipher_metadata, ULONG public_cipher_metadata_size,
+ VOID *public_auth_metadata, ULONG public_auth_metadata_size, VOID *tls_ecc_curves);
+ UINT(*nx_secure_generate_client_key_exchange)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite,
+ NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials,
+ UCHAR *data_buffer, ULONG buffer_length, ULONG *output_size,
+ VOID *public_cipher_metadata, ULONG public_cipher_metadata_size,
+ VOID *public_auth_metadata, ULONG public_auth_metadata_size);
+#endif
+#ifndef NX_SECURE_TLS_SERVER_DISABLED
+ UINT(*nx_secure_process_client_key_exchange)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version,
+ UCHAR *packet_buffer, UINT message_length, USHORT *received_remote_credentials,
+ NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials,
+ VOID *public_cipher_metadata, ULONG public_cipher_metadata_size,
+ VOID *public_auth_metadata, ULONG public_auth_metadata_size, VOID *tls_ecc_curves);
+ UINT(*nx_secure_generate_server_key_exchange)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, UCHAR tls_1_3,
+ NX_SECURE_TLS_CRYPTO *tls_crypto_table, NX_SECURE_TLS_HANDSHAKE_HASH *tls_handshake_hash,
+ NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials,
+ UCHAR *data_buffer, ULONG buffer_length, ULONG *output_size,
+ VOID *public_cipher_metadata, ULONG public_cipher_metadata_size,
+ VOID *public_auth_metadata, ULONG public_auth_metadata_size, VOID *tls_ecc_curves);
+#endif
+ UINT (*nx_secure_verify_mac)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, UCHAR *mac_secret, ULONG sequence_num[NX_SECURE_TLS_SEQUENCE_NUMBER_SIZE],
+ UCHAR *header_data, USHORT header_length, NX_PACKET *packet_ptr, ULONG offset, UINT *length,
+ VOID *hash_mac_metadata, ULONG hash_mac_metadata_size);
+ UINT (*nx_secure_remote_certificate_verify)(NX_SECURE_X509_CERTIFICATE_STORE *store,
+ NX_SECURE_X509_CERT *certificate, ULONG current_time);
+ UINT (*nx_secure_trusted_certificate_add)(NX_SECURE_X509_CERTIFICATE_STORE *store,
+ NX_SECURE_X509_CERT *certificate);
} NX_SECURE_TLS_SESSION;
/* TLS record types. */
@@ -1421,11 +1513,11 @@ UINT _nx_secure_tls_handshake_hash_init(NX_SECURE_TLS_SESSION *tls_session);
UINT _nx_secure_tls_handshake_hash_update(NX_SECURE_TLS_SESSION *tls_session, UCHAR *data,
UINT length);
UINT _nx_secure_tls_handshake_process(NX_SECURE_TLS_SESSION *tls_session, UINT wait_option);
-UINT _nx_secure_tls_hash_record(NX_SECURE_TLS_SESSION *tls_session,
+UINT _nx_secure_tls_hash_record(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite,
ULONG sequence_num[NX_SECURE_TLS_SEQUENCE_NUMBER_SIZE],
UCHAR *header, UINT header_length, NX_PACKET *packet_ptr,
ULONG offset, UINT length, UCHAR *record_hash, UINT *hash_length,
- UCHAR *mac_secret);
+ UCHAR *mac_secret, VOID *metadata, ULONG metadata_size);
UINT _nx_secure_tls_key_material_init(NX_SECURE_TLS_KEY_MATERIAL *key_material);
VOID _nx_secure_tls_map_error_to_alert(UINT error_number, UINT *alert_number,
UINT *alert_level);
@@ -1534,10 +1626,15 @@ UINT _nx_secure_tls_session_receive_records(NX_SECURE_TLS_SESSION *tls_session,
UINT _nx_secure_tls_verify_mac(NX_SECURE_TLS_SESSION *tls_session, UCHAR *header_data,
USHORT header_length, NX_PACKET *packet_ptr, ULONG offset, UINT *length);
#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE
-UINT _nx_secure_tls_ecc_generate_keys(NX_SECURE_TLS_SESSION *tls_session, UINT ecc_named_curve, USHORT sign_key,
- UCHAR *public_key, UINT *public_key_size, NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecc_data);
-UINT _nx_secure_tls_find_curve_method(NX_SECURE_TLS_SESSION *tls_session,
- USHORT named_curve, const NX_CRYPTO_METHOD **curve_method, UINT *curve_priority);
+UINT _nx_secure_tls_ecc_generate_keys(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, UCHAR tls_1_3,
+ NX_SECURE_TLS_CRYPTO *tls_crypto_table, NX_SECURE_TLS_HANDSHAKE_HASH *tls_handshake_hash,
+ NX_SECURE_TLS_ECC *tls_ecc_curves, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material,
+ NX_SECURE_TLS_CREDENTIALS *tls_credentials, UINT ecc_named_curve, USHORT sign_key,
+ UCHAR *public_key, UINT *public_key_size, NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecc_data,
+ VOID *public_cipher_metadata, ULONG public_cipher_metadata_size,
+ VOID *public_auth_metadata, ULONG public_auth_metadata_size);
+UINT _nx_secure_tls_find_curve_method(NX_SECURE_TLS_ECC *tls_ecc, USHORT named_curve,
+ const NX_CRYPTO_METHOD **curve_method, UINT *curve_priority);
UINT _nx_secure_tls_proc_clienthello_sec_sa_extension(NX_SECURE_TLS_SESSION *tls_session,
NX_SECURE_TLS_HELLO_EXTENSION *exts,
UINT num_extensions,
@@ -1607,6 +1704,8 @@ UINT _nx_secure_tls_session_delete(NX_SECURE_TLS_SESSION *tls_session);
UINT _nx_secure_tls_session_end(NX_SECURE_TLS_SESSION *tls_session, UINT wait_option);
UINT _nx_secure_tls_session_packet_buffer_set(NX_SECURE_TLS_SESSION *session_ptr,
UCHAR *buffer_ptr, ULONG buffer_size);
+UINT _nx_secure_tls_session_packet_pool_set(NX_SECURE_TLS_SESSION *tls_session,
+ NX_PACKET_POOL *packet_pool);
UINT _nx_secure_tls_session_protocol_version_override(NX_SECURE_TLS_SESSION *tls_session,
USHORT protocol_version);
UINT _nx_secure_tls_session_receive(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET **packet_ptr_ptr,
@@ -1640,7 +1739,7 @@ UINT _nx_secure_tls_packet_allocate(NX_SECURE_TLS_SESSION *tls_session, NX_PACKE
#if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE)
UINT _nx_secure_tls_psk_add(NX_SECURE_TLS_SESSION *tls_session, UCHAR *pre_shared_key, UINT psk_length,
UCHAR *psk_identity, UINT identity_length, UCHAR *hint, UINT hint_length);
-UINT _nx_secure_tls_psk_find(NX_SECURE_TLS_SESSION *tls_session, UCHAR **psk_data, UINT *psk_length,
+UINT _nx_secure_tls_psk_find(NX_SECURE_TLS_CREDENTIALS *tls_credentials, UCHAR **psk_data, UINT *psk_length,
UCHAR *psk_identity_hint, UINT identity_length, UINT *psk_store_index);
UINT _nx_secure_tls_client_psk_set(NX_SECURE_TLS_SESSION *tls_session, UCHAR *pre_shared_key, UINT psk_length,
UCHAR *psk_identity, UINT identity_length, UCHAR *hint, UINT hint_length);
@@ -1699,6 +1798,8 @@ UINT _nxe_secure_tls_session_delete(NX_SECURE_TLS_SESSION *tls_session);
UINT _nxe_secure_tls_session_end(NX_SECURE_TLS_SESSION *tls_session, UINT wait_option);
UINT _nxe_secure_tls_session_packet_buffer_set(NX_SECURE_TLS_SESSION *session_ptr,
UCHAR *buffer_ptr, ULONG buffer_size);
+UINT _nxe_secure_tls_session_packet_pool_set(NX_SECURE_TLS_SESSION *tls_session,
+ NX_PACKET_POOL *packet_pool);
UINT _nxe_secure_tls_session_protocol_version_override(NX_SECURE_TLS_SESSION *tls_session,
USHORT protocol_version);
UINT _nxe_secure_tls_session_receive(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET **packet_ptr_ptr,
@@ -1738,6 +1839,52 @@ UINT _nxe_secure_tls_client_psk_set(NX_SECURE_TLS_SESSION *tls_session, UCHAR *p
UCHAR *psk_identity, UINT identity_length, UCHAR *hint, UINT hint_length);
#endif
+UINT _nx_secure_process_server_key_exchange(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, NX_SECURE_TLS_CRYPTO *tls_crypto_table,
+ USHORT protocol_version, UCHAR *packet_buffer, UINT message_length,
+ NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials,
+ NX_SECURE_TLS_HANDSHAKE_HASH *tls_handshake_hash,
+ VOID *public_cipher_metadata, ULONG public_cipher_metadata_size,
+ VOID *public_auth_metadata, ULONG public_auth_metadata_size, VOID *tls_ecc_curves);
+UINT _nx_secure_process_client_key_exchange(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version,
+ UCHAR *packet_buffer, UINT message_length, USHORT *received_remote_credentials,
+ NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials,
+ VOID *public_cipher_metadata, ULONG public_cipher_metadata_size,
+ VOID *public_auth_metadata, ULONG public_auth_metadata_size, VOID *tls_ecc_curves);
+UINT _nx_secure_generate_premaster_secret(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material,
+ NX_SECURE_TLS_CREDENTIALS *tls_credentials, UINT session_type, USHORT *received_remote_credentials,
+ VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, VOID *tls_ecc_curves);
+UINT _nx_secure_generate_client_key_exchange(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite,
+ NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials,
+ UCHAR *data_buffer, ULONG buffer_length, ULONG *output_size,
+ VOID *public_cipher_metadata, ULONG public_cipher_metadata_size,
+ VOID *public_auth_metadata, ULONG public_auth_metadata_size);
+UINT _nx_secure_generate_server_key_exchange(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, UCHAR tls_1_3,
+ NX_SECURE_TLS_CRYPTO *tls_crypto_table, NX_SECURE_TLS_HANDSHAKE_HASH *tls_handshake_hash,
+ NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials,
+ UCHAR *data_buffer, ULONG buffer_length, ULONG *output_size,
+ VOID *public_cipher_metadata, ULONG public_cipher_metadata_size,
+ VOID *public_auth_metadata, ULONG public_auth_metadata_size, VOID *tls_ecc_curves);
+UINT _nx_secure_generate_master_secret(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version,
+ const NX_CRYPTO_METHOD *session_prf_method, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material,
+ UCHAR *pre_master_sec, UINT pre_master_sec_size, UCHAR *master_sec,
+ VOID *prf_metadata, ULONG prf_metadata_size);
+UINT _nx_secure_generate_session_keys(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version,
+ const NX_CRYPTO_METHOD *session_prf_method, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material,
+ UCHAR *master_sec, VOID *prf_metadata, ULONG prf_metadata_size);
+UINT _nx_secure_session_keys_set(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material,
+ UINT key_material_data_size, UINT is_client, UCHAR *session_cipher_initialized,
+ VOID *session_cipher_metadata, VOID **session_cipher_handler, ULONG session_cipher_metadata_size);
+UINT _nx_secure_verify_mac(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, UCHAR *mac_secret, ULONG sequence_num[NX_SECURE_TLS_SEQUENCE_NUMBER_SIZE],
+ UCHAR *header_data, USHORT header_length, NX_PACKET *packet_ptr, ULONG offset, UINT *length,
+ VOID *hash_mac_metadata, ULONG hash_mac_metadata_size);
+UINT _nx_secure_remote_certificate_verify(NX_SECURE_X509_CERTIFICATE_STORE *store,
+ NX_SECURE_X509_CERT *certificate, ULONG current_time);
+UINT _nx_secure_trusted_certificate_add(NX_SECURE_X509_CERTIFICATE_STORE *store,
+ NX_SECURE_X509_CERT *certificate);
+#ifdef NX_SECURE_CUSTOM_SECRET_GENERATION
+UINT nx_secure_custom_secret_generation_init(NX_SECURE_TLS_SESSION *tls_session);
+#endif
+
/* TLS component data declarations follow. */
/* Determine if the initialization function of this component is including
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls_api.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls_api.h
index ab180e1b..0aa62ca0 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls_api.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls_api.h
@@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* nx_secure_tls_api.h PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -44,6 +44,9 @@
/* 05-19-2020 Timothy Stapko Initial Version 6.0 */
/* 09-30-2020 Timothy Stapko Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yanwu Cai Modified comment(s), and added*/
+/* API to set packet pool, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -94,6 +97,7 @@ extern "C" {
#define nx_secure_tls_session_delete _nx_secure_tls_session_delete
#define nx_secure_tls_session_end _nx_secure_tls_session_end
#define nx_secure_tls_session_packet_buffer_set _nx_secure_tls_session_packet_buffer_set
+#define nx_secure_tls_session_packet_pool_set _nx_secure_tls_session_packet_pool_set
#define nx_secure_tls_session_protocol_version_override _nx_secure_tls_session_protocol_version_override
#define nx_secure_tls_session_receive _nx_secure_tls_session_receive
#define nx_secure_tls_session_renegotiate _nx_secure_tls_session_renegotiate
@@ -136,6 +140,7 @@ extern "C" {
#define nx_secure_tls_session_delete _nxe_secure_tls_session_delete
#define nx_secure_tls_session_end _nxe_secure_tls_session_end
#define nx_secure_tls_session_packet_buffer_set _nxe_secure_tls_session_packet_buffer_set
+#define nx_secure_tls_session_packet_pool_set _nxe_secure_tls_session_packet_pool_set
#define nx_secure_tls_session_protocol_version_override _nxe_secure_tls_session_protocol_version_override
#define nx_secure_tls_session_receive _nxe_secure_tls_session_receive
#define nx_secure_tls_session_renegotiate _nxe_secure_tls_session_renegotiate
@@ -218,6 +223,8 @@ UINT nx_secure_tls_session_delete(NX_SECURE_TLS_SESSION *tls_session);
UINT nx_secure_tls_session_end(NX_SECURE_TLS_SESSION *tls_session, UINT wait_option);
UINT nx_secure_tls_session_packet_buffer_set(NX_SECURE_TLS_SESSION *session_ptr,
UCHAR *buffer_ptr, ULONG buffer_size);
+UINT nx_secure_tls_session_packet_pool_set(NX_SECURE_TLS_SESSION *tls_session,
+ NX_PACKET_POOL *packet_pool);
UINT nx_secure_tls_session_protocol_version_override(NX_SECURE_TLS_SESSION *tls_session,
USHORT protocol_version);
UINT nx_secure_tls_session_receive(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET **packet_ptr_ptr,
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_user_sample.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_user_sample.h
index 36712225..7b1c66d6 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_user_sample.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_user_sample.h
@@ -26,7 +26,7 @@
/* PORT SPECIFIC C INFORMATION RELEASE */
/* */
/* nx_secure_user.h PORTABLE C */
-/* 6.1.9 */
+/* 6.2.0 */
/* */
/* AUTHOR */
/* */
@@ -55,6 +55,9 @@
/* initiated renegotiation for */
/* TLS server instances, */
/* resulting in version 6.1.9 */
+/* 10-31-2022 Yanwu Cai Modified comment(s), added */
+/* macro to custom secret size,*/
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
@@ -259,12 +262,24 @@
#define NX_SECURE_TLS_MINIMUM_MESSAGE_BUFFER_SIZE 4000
*/
-/* NX_SECURE_TLS_PREMASTER_SIZE defines the sie of pre-master secret.
+/* NX_SECURE_TLS_PREMASTER_SIZE defines the size of pre-master secret.
The default value is 48. */
/*
#define NX_SECURE_TLS_PREMASTER_SIZE 48
*/
+/* NX_SECURE_TLS_MASTER_SIZE defines the size of master secret.
+ The default value is 48. */
+/*
+ #define NX_SECURE_TLS_MASTER_SIZE 48
+*/
+
+/* NX_SECURE_TLS_KEY_MATERIAL_SIZE defines the size of key material.
+ The default value is (2 * (NX_SECURE_TLS_MAX_HASH_SIZE + NX_SECURE_TLS_MAX_KEY_SIZE + NX_SECURE_TLS_MAX_IV_SIZE)). */
+/*
+ #define NX_SECURE_TLS_KEY_MATERIAL_SIZE (2 * (NX_SECURE_TLS_MAX_HASH_SIZE + NX_SECURE_TLS_MAX_KEY_SIZE + NX_SECURE_TLS_MAX_IV_SIZE))
+*/
+
/* NX_SECURE_TLS_CLIENT_DISABLED disables TLS server. By default TLS server is enabled. */
/*
#define NX_SECURE_TLS_SERVER_DISABLED
@@ -300,8 +315,14 @@
vulnerability. */
/*
#define NX_SECURE_TLS_DISABLE_CLIENT_INITIATED_RENEGOTIATION
- */
+*/
+/* NX_SECURE_CUSTOM_SECRET_GENERATION enables the user to pass pointers of customized secret generation functions to
+ TLS in the user defined nx_secure_custom_secret_generation_init function. This will allow TLS to use customized
+ secret generation functions. */
+/*
+ #define NX_SECURE_CUSTOM_SECRET_GENERATION
+*/
/* NX_SECURE_X509_DISABLE_CRL disables X509 Certificate Revocation List check.
By default this feature is enabled. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_x509.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_x509.h
index 1825dd60..a0189ed8 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_x509.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_x509.h
@@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* nx_secure_x509.h PORTABLE C */
-/* 6.1.10 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -55,6 +55,10 @@
/* ignored public key in EC */
/* private key, */
/* resulting in version 6.1.10 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* checked expiration for all */
+/* the certs in the chain, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@@ -936,7 +940,7 @@ UINT _nx_secure_x509_certificate_verify(NX_SECURE_X509_CERTIFICATE_STORE *store,
/* Verify a given certificate chain to see if the end-entity certificate can be traced through the chain to a trust anchor. */
UINT _nx_secure_x509_certificate_chain_verify(NX_SECURE_X509_CERTIFICATE_STORE *store,
- NX_SECURE_X509_CERT *certificate);
+ NX_SECURE_X509_CERT *certificate, ULONG current_time);
/* Parse an OID string, returning an internally-used constant (defined above) for use in other parsing. */
VOID _nx_secure_x509_oid_parse(const UCHAR *oid, ULONG length, UINT *oid_value);
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/ports/nx_secure_port.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/ports/nx_secure_port.h
index 8d4237a1..32b23984 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/ports/nx_secure_port.h
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/ports/nx_secure_port.h
@@ -69,7 +69,7 @@
#ifdef NX_SECURE_SYSTEM_INIT
CHAR _nx_secure_version_id[] =
- "Copyright (c) Microsoft Corporation. All rights reserved. * NetX Secure Generic Version G6.1.11 *";
+ "Copyright (c) Microsoft Corporation. All rights reserved. * NetX Secure Generic Version G6.2.0 *";
#else
extern CHAR _nx_secure_version_id[];
#endif
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_client_handshake.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_client_handshake.c
index 8d7697e7..54bc4595 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_client_handshake.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_client_handshake.c
@@ -32,7 +32,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_secure_dtls_client_handshake PORTABLE C */
-/* 6.1.10 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -72,7 +72,6 @@
/* _nx_secure_tls_generate_premaster_secret */
/* Generate premaster secret */
/* _nx_secure_tls_handshake_hash_update Update Finished hash */
-/* _nx_secure_tls_map_error_to_alert Map internal error to alert */
/* _nx_secure_tls_process_certificate_request */
/* Process certificate request */
/* _nx_secure_tls_process_finished Process Finished message */
@@ -81,7 +80,6 @@
/* _nx_secure_tls_process_server_key_exchange */
/* Process ServerKeyExchange */
/* _nx_secure_tls_process_serverhello Process ServerHello */
-/* _nx_secure_tls_send_alert Send DTLS alert */
/* _nx_secure_tls_send_certificate Send DTLS certificate */
/* _nx_secure_tls_send_certificate_verify */
/* Send certificate verify */
@@ -118,6 +116,9 @@
/* 01-31-2022 Timothy Stapko Modified comment(s), */
/* fixed out-of-order handling,*/
/* resulting in version 6.1.10 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* removed duplicated alert, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_secure_dtls_client_handshake(NX_SECURE_DTLS_SESSION *dtls_session, UCHAR *packet_buffer,
@@ -131,9 +132,6 @@ UINT message_length;
UCHAR *data_start = NX_NULL;
NX_PACKET *send_packet = NX_NULL;
NX_PACKET_POOL *packet_pool;
-UINT error_number;
-UINT alert_number;
-UINT alert_level;
UINT message_seq;
UINT fragment_offset;
UINT fragment_length;
@@ -362,24 +360,8 @@ NX_SECURE_TLS_SESSION *tls_session;
/* Check for errors in processing messages. */
if (status != NX_SECURE_TLS_SUCCESS)
{
- /* Get our alert number and level from our status. */
- error_number = status;
- _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level);
- /* Release the protection before suspending on nx_packet_allocate. */
- tx_mutex_put(&_nx_secure_tls_protection);
-
- status = _nx_secure_dtls_packet_allocate(dtls_session, packet_pool, &send_packet, wait_option);
-
- /* Get the protection after nx_packet_allocate. */
- tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
-
- if (status == NX_SUCCESS)
- {
- _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level);
- _nx_secure_dtls_send_record(dtls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option);
- }
- return(error_number);
+ return(status);
}
/* Now take any actions based on state set in the message processing. */
@@ -593,29 +575,11 @@ NX_SECURE_TLS_SESSION *tls_session;
}
/* If we have an error at this point, we have experienced a problem in sending
- handshake messages, which is some type of internal issue. Send an alert
- back to the remote host indicating the error. */
+ handshake messages, which is some type of internal issue. */
if (status != NX_SUCCESS)
{
- /* Get our alert number and level from our status. */
- error_number = status;
- _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level);
- /* Release the protection before suspending on nx_packet_allocate. */
- tx_mutex_put(&_nx_secure_tls_protection);
-
- status = _nx_secure_dtls_packet_allocate(dtls_session, packet_pool, &send_packet, wait_option);
-
- /* Get the protection after nx_packet_allocate. */
- tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
-
- if (status == NX_SUCCESS)
- {
- _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level);
- _nx_secure_dtls_send_record(dtls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option);
- }
-
- return(error_number);
+ return(status);
}
/* Advance the buffer pointer past the fragment. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_send_record.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_send_record.c
index 24fd00ae..d3cc68b0 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_send_record.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_send_record.c
@@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_secure_dtls_send_record PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -86,6 +86,9 @@
/* verified memcpy use cases, */
/* released packet securely, */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* checked seq number overflow,*/
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_secure_dtls_send_record(NX_SECURE_DTLS_SESSION *dtls_session, NX_PACKET *send_packet,
@@ -169,6 +172,14 @@ UCHAR epoch_seq_num[8];
{
/* Check for overflow of the 32-bit number. */
tls_session -> nx_secure_tls_local_sequence_number[1]++;
+
+ if (tls_session -> nx_secure_tls_local_sequence_number[1] == 0)
+ {
+
+ /* Check for overflow of the 64-bit unsigned number. As it should not reach here
+ in practical, we return a general error to prevent overflow theoretically. */
+ return(NX_NOT_SUCCESSFUL);
+ }
}
tls_session -> nx_secure_tls_local_sequence_number[0]++;
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_server_handshake.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_server_handshake.c
index 2c7fe168..b1f2482d 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_server_handshake.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_server_handshake.c
@@ -33,7 +33,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_secure_dtls_server_handshake PORTABLE C */
-/* 6.1.10 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -73,11 +73,9 @@
/* _nx_secure_tls_generate_keys Generate session keys */
/* _nx_secure_tls_handshake_hash_init Initialize Finished hash */
/* _nx_secure_tls_handshake_hash_update Update Finished hash */
-/* _nx_secure_tls_map_error_to_alert Map internal error to alert */
/* _nx_secure_tls_process_client_key_exchange */
/* Process key exchange */
/* _nx_secure_tls_process_finished Process Finished message */
-/* _nx_secure_tls_send_alert Send TLS alert */
/* _nx_secure_tls_send_certificate Send TLS certificate */
/* _nx_secure_tls_send_changecipherspec Send ChangeCipherSpec */
/* _nx_secure_tls_send_finished Send Finished message */
@@ -118,6 +116,9 @@
/* 01-31-2022 Timothy Stapko Modified comment(s), */
/* fixed out-of-order handling,*/
/* resulting in version 6.1.10 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* removed duplicated alert, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_secure_dtls_server_handshake(NX_SECURE_DTLS_SESSION *dtls_session, UCHAR *packet_buffer,
@@ -135,10 +136,7 @@ NX_PACKET *send_packet;
NX_PACKET_POOL *packet_pool;
UCHAR *packet_start;
NX_SECURE_TLS_SESSION *tls_session;
-UINT error_number;
-UINT alert_number;
-UINT alert_level;
-UCHAR *fragment_buffer;
+UCHAR *fragment_buffer;
/* Basic state machine for handshake:
@@ -361,22 +359,8 @@ UCHAR *fragment_buffer;
/* Check for errors in processing messages. */
if (status != NX_SECURE_TLS_SUCCESS)
{
- /* Get our alert number and level from our status. */
- error_number = status;
- _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level);
- /* Release the protection before suspending on nx_packet_allocate. */
- tx_mutex_put(&_nx_secure_tls_protection);
-
- status = _nx_secure_dtls_packet_allocate(dtls_session, packet_pool, &send_packet, wait_option);
-
- /* Get the protection after nx_packet_allocate. */
- tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
-
- _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level);
-
- _nx_secure_dtls_send_record(dtls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option);
- return(error_number);
+ return(status);
}
/* Hash this handshake message. We do not hash HelloRequest messages, but since only the server will send them,
@@ -619,32 +603,6 @@ UCHAR *fragment_buffer;
}
- /* If we have an error at this point, we have experienced a problem in sending
- handshake messages, which is some type of internal issue. Send an alert
- back to the remote host indicating the error. */
- if (status != NX_SUCCESS)
- {
- /* Get our alert number and level from our status. */
- error_number = status;
- _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level);
-
- /* Release the protection before suspending on nx_packet_allocate. */
- tx_mutex_put(&_nx_secure_tls_protection);
-
- status = _nx_secure_dtls_packet_allocate(dtls_session, packet_pool, &send_packet, wait_option);
-
- /* Get the protection after nx_packet_allocate. */
- tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
-
- if (status == NX_SUCCESS)
- {
- _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level);
- _nx_secure_dtls_send_record(dtls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option);
- }
-
- return(error_number);
- }
-
return(status);
#else /* TLS Server disabled. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_cache.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_cache.c
index 1f35e4b0..c9bafa71 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_cache.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_cache.c
@@ -30,7 +30,7 @@
/* FUNCTION RELEASE */
/* */
/* nx_secure_dtls_session_cache_delete PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -66,6 +66,10 @@
/* 05-19-2020 Timothy Stapko Initial Version 6.0 */
/* 09-30-2020 Timothy Stapko Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* fixed compiler errors when */
+/* IPv4 is disabled, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
VOID nx_secure_dtls_session_cache_delete(NX_SECURE_DTLS_SERVER *dtls_server, NXD_ADDRESS *ip_address, UINT remote_port, UINT local_port)
@@ -95,6 +99,7 @@ UINT i;
{
continue;
}
+#ifndef NX_DISABLE_IPV4
if (ip_address -> nxd_ip_version == NX_IP_VERSION_V4)
{
if (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v4 !=
@@ -103,13 +108,18 @@ UINT i;
continue;
}
}
+#endif /* !NX_DISABLE_IPV4 */
+
#ifdef FEATURE_NX_IPV6
- else if ((session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] != ip_address -> nxd_ip_address.v6[0]) ||
- (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] != ip_address -> nxd_ip_address.v6[1]) ||
- (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] != ip_address -> nxd_ip_address.v6[2]) ||
- (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] != ip_address -> nxd_ip_address.v6[3]))
+ if (ip_address -> nxd_ip_version == NX_IP_VERSION_V6)
{
- continue;
+ if ((session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] != ip_address -> nxd_ip_address.v6[0]) ||
+ (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] != ip_address -> nxd_ip_address.v6[1]) ||
+ (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] != ip_address -> nxd_ip_address.v6[2]) ||
+ (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] != ip_address -> nxd_ip_address.v6[3]))
+ {
+ continue;
+ }
}
#endif /* FEATURE_NX_IPV6 */
@@ -225,7 +235,7 @@ UINT i;
/* FUNCTION RELEASE */
/* */
/* nx_secure_dtls_session_cache_find PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -263,6 +273,10 @@ UINT i;
/* 05-19-2020 Timothy Stapko Initial Version 6.0 */
/* 09-30-2020 Timothy Stapko Modified comment(s), */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* fixed compiler errors when */
+/* IPv4 is disabled, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT nx_secure_dtls_session_cache_find(NX_SECURE_DTLS_SERVER *dtls_server, NX_SECURE_DTLS_SESSION **dtls_session, NXD_ADDRESS *ip_address, UINT remote_port, UINT local_port)
@@ -301,6 +315,7 @@ UINT i;
}
/* Check actual remote IP address value. */
+#ifndef NX_DISABLE_IPV4
if (ip_address -> nxd_ip_version == NX_IP_VERSION_V4)
{
if (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v4 ==
@@ -315,19 +330,24 @@ UINT i;
return(NX_SUCCESS);
}
}
+#endif /* !NX_DISABLE_IPV4 */
+
#ifdef FEATURE_NX_IPV6
- else if ((session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] == ip_address -> nxd_ip_address.v6[0]) &&
- (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] == ip_address -> nxd_ip_address.v6[1]) &&
- (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] == ip_address -> nxd_ip_address.v6[2]) &&
- (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] == ip_address -> nxd_ip_address.v6[3]))
+ if (ip_address -> nxd_ip_version == NX_IP_VERSION_V6)
{
+ if ((session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] == ip_address -> nxd_ip_address.v6[0]) &&
+ (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] == ip_address -> nxd_ip_address.v6[1]) &&
+ (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] == ip_address -> nxd_ip_address.v6[2]) &&
+ (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] == ip_address -> nxd_ip_address.v6[3]))
+ {
- /* Release the protection. */
- tx_mutex_put(&_nx_secure_tls_protection);
+ /* Release the protection. */
+ tx_mutex_put(&_nx_secure_tls_protection);
- /* Return the session. */
- *dtls_session = &session_array[i];
- return(NX_SUCCESS);
+ /* Return the session. */
+ *dtls_session = &session_array[i];
+ return(NX_SUCCESS);
+ }
}
#endif /* FEATURE_NX_IPV6 */
}
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_receive.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_receive.c
index 128c454e..b3899282 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_receive.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_receive.c
@@ -29,7 +29,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_secure_dtls_session_receive PORTABLE C */
-/* 6.1.10 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -82,7 +82,11 @@
/* resulting in version 6.1 */
/* 01-31-2022 Timothy Stapko Modified comment(s), */
/* fixed out-of-order handling,*/
-/* resulting in version 6.1.10 */
+/* resulting in version 6.1.10 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* fixed compiler errors when */
+/* IPv4 is disabled, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_secure_dtls_session_receive(NX_SECURE_DTLS_SESSION *dtls_session,
@@ -230,6 +234,7 @@ UINT source_port;
}
else
{
+#ifndef NX_DISABLE_IPV4
if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_version == NX_IP_VERSION_V4)
{
@@ -239,8 +244,10 @@ UINT source_port;
status = NX_CONTINUE;
}
}
+#endif /* !NX_DISABLE_IPV4 */
+
#ifdef FEATURE_NX_IPV6
- else if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_version == NX_IP_VERSION_V6)
+ if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_version == NX_IP_VERSION_V6)
{
/* Compare the IPv6 address. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_send.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_send.c
index 07a5837b..01de1eeb 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_send.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_send.c
@@ -29,7 +29,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_secure_dtls_session_send PORTABLE C */
-/* 6.1 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -69,6 +69,10 @@
/* 09-30-2020 Timothy Stapko Modified comment(s), */
/* verified memcpy use cases, */
/* resulting in version 6.1 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* fixed compiler errors when */
+/* IPv4 is disabled, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_secure_dtls_session_send(NX_SECURE_DTLS_SESSION *dtls_session, NX_PACKET *packet_ptr,
@@ -98,32 +102,41 @@ UINT status;
/* IP address and port don't match - probably caller error. */
return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH);
}
- else if (ip_address -> nxd_ip_version == NX_IP_VERSION_V4)
+ else
{
- if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v4 != ip_address -> nxd_ip_address.v4)
+#ifndef NX_DISABLE_IPV4
+ if (ip_address -> nxd_ip_version == NX_IP_VERSION_V4)
{
+ if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v4 != ip_address -> nxd_ip_address.v4)
+ {
- /* Release the protection. */
- tx_mutex_put(&_nx_secure_tls_protection);
+ /* Release the protection. */
+ tx_mutex_put(&_nx_secure_tls_protection);
- /* IP address and port don't match - probably caller error. */
- return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH);
+ /* IP address and port don't match - probably caller error. */
+ return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH);
+ }
}
- }
-#ifdef FEATURE_NX_IPV6
- else if ((dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] != ip_address -> nxd_ip_address.v6[0]) ||
- (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] != ip_address -> nxd_ip_address.v6[1]) ||
- (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] != ip_address -> nxd_ip_address.v6[2]) ||
- (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] != ip_address -> nxd_ip_address.v6[3]))
- {
+#endif /* !NX_DISABLE_IPV4 */
- /* Release the protection. */
- tx_mutex_put(&_nx_secure_tls_protection);
-
- /* IP address and port don't match - probably caller error. */
- return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH);
- }
+#ifdef FEATURE_NX_IPV6
+ if (ip_address -> nxd_ip_version == NX_IP_VERSION_V6)
+ {
+ if ((dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] != ip_address -> nxd_ip_address.v6[0]) ||
+ (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] != ip_address -> nxd_ip_address.v6[1]) ||
+ (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] != ip_address -> nxd_ip_address.v6[2]) ||
+ (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] != ip_address -> nxd_ip_address.v6[3]))
+ {
+
+ /* Release the protection. */
+ tx_mutex_put(&_nx_secure_tls_protection);
+
+ /* IP address and port don't match - probably caller error. */
+ return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH);
+ }
+ }
#endif /* FEATURE_NX_IPV6 */
+ }
status = _nx_secure_dtls_send_record(dtls_session, packet_ptr, NX_SECURE_TLS_APPLICATION_DATA, NX_WAIT_FOREVER);
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_client_handshake.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_client_handshake.c
index 0c2e7dcd..9e39bd63 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_client_handshake.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_client_handshake.c
@@ -30,7 +30,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_secure_tls_1_3_client_handshake PORTABLE C */
-/* 6.1.4 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -116,6 +116,10 @@
/* support for fragmented TLS */
/* Handshake messages, */
/* resulting in version 6.1.4 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), and */
+/* updated alert message for */
+/* downgrade protection, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
@@ -155,9 +159,6 @@ UINT packet_buffer_length = data_length;
UCHAR *packet_start;
NX_PACKET *send_packet = NX_NULL;
NX_PACKET_POOL *packet_pool;
-UINT error_number;
-UINT alert_number;
-UINT alert_level;
const NX_CRYPTO_METHOD
*method_ptr = NX_NULL;
const UCHAR *server_random;
@@ -286,7 +287,7 @@ const UCHAR *server_random;
if (NX_SECURE_MEMCMP(&(tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random[24]),
server_random, 8) == 0)
{
- status = NX_SECURE_TLS_UNKNOWN_TLS_VERSION;
+ status = NX_SECURE_TLS_DOWNGRADE_DETECTED;
}
else
{
@@ -387,29 +388,8 @@ const UCHAR *server_random;
/* Check for errors in processing messages. */
if (status != NX_SECURE_TLS_SUCCESS)
{
- /* Get our alert number and level from our status. */
- error_number = status;
- _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level);
- /* Release the protection before suspending on nx_packet_allocate. */
- tx_mutex_put(&_nx_secure_tls_protection);
-
- status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option);
-
- /* Get the protection after nx_packet_allocate. */
- tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
-
- if (status == NX_SUCCESS)
- {
- _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level);
- status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option);
-
- if (status != NX_SUCCESS)
- {
- nx_secure_tls_packet_release(send_packet);
- }
- }
- return(error_number);
+ return(status);
}
/* Now take any actions based on state set in the message processing. */
@@ -687,34 +667,11 @@ const UCHAR *server_random;
}
/* If we have an error at this point, we have experienced a problem in sending
- handshake messages, which is some type of internal issue. Send an alert
- back to the remote host indicating the error. */
+ handshake messages, which is some type of internal issue. */
if (status != NX_SUCCESS)
{
- /* Get our alert number and level from our status. */
- error_number = status;
- _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level);
-
- /* Release the protection before suspending on nx_packet_allocate. */
- tx_mutex_put(&_nx_secure_tls_protection);
- status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option);
-
- /* Get the protection after nx_packet_allocate. */
- tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
-
- if (status == NX_SUCCESS)
- {
- _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level);
- status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option);
-
- if (status != NX_SUCCESS)
- {
- nx_secure_tls_packet_release(send_packet);
- }
- }
-
- return(error_number);
+ return(status);
}
/* Advance the buffer pointer past the message. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_crypto_init.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_crypto_init.c
index 49abb961..5f5fa50e 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_crypto_init.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_crypto_init.c
@@ -33,7 +33,7 @@ extern NX_SECURE_TLS_ECC _nx_secure_tls_ecc_info;
/* FUNCTION RELEASE */
/* */
/* _nx_secure_tls_1_3_crypto_init PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -71,6 +71,9 @@ extern NX_SECURE_TLS_ECC _nx_secure_tls_ecc_info;
/* 05-19-2020 Timothy Stapko Initial Version 6.0 */
/* 09-30-2020 Timothy Stapko Modified comment(s), */
/* resulting in version 6.1 */
+/* 10-31-2022 Yanwu Cai Modified comment(s), */
+/* updated parameters list, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
#if (NX_SECURE_TLS_TLS_1_3_ENABLED)
@@ -103,17 +106,24 @@ NX_SECURE_TLS_ECC *ecc_info;
ecdhe_data = &tls_session -> nx_secure_tls_key_material.nx_secure_tls_ecc_key_data[i];
/* Save off the curve ID so we can select the server's chosen key/curve later. */
- ecdhe_data->nx_secure_tls_ecdhe_named_curve = ecc_info -> nx_secure_tls_ecc_supported_groups[i];
+ ecdhe_data -> nx_secure_tls_ecdhe_named_curve = ecc_info -> nx_secure_tls_ecc_supported_groups[i];
/* Output the public key to our handshake data structure - we need the length of that buffer. */
- length = sizeof(ecdhe_data->nx_secure_tls_ecdhe_public_key);
+ length = sizeof(ecdhe_data -> nx_secure_tls_ecdhe_public_key);
/* Generate ECC keys and store in our TLS session. */
- status = _nx_secure_tls_ecc_generate_keys(tls_session, ecdhe_data -> nx_secure_tls_ecdhe_named_curve, NX_FALSE,
- ecdhe_data->nx_secure_tls_ecdhe_public_key, &length, ecdhe_data);
+ status = _nx_secure_tls_ecc_generate_keys(tls_session -> nx_secure_tls_session_ciphersuite, tls_session -> nx_secure_tls_protocol_version,
+ tls_session -> nx_secure_tls_1_3, tls_session -> nx_secure_tls_crypto_table,
+ &tls_session -> nx_secure_tls_handshake_hash, ecc_info, &tls_session -> nx_secure_tls_key_material,
+ &tls_session -> nx_secure_tls_credentials, ecdhe_data -> nx_secure_tls_ecdhe_named_curve, NX_FALSE,
+ ecdhe_data -> nx_secure_tls_ecdhe_public_key, &length, ecdhe_data,
+ tls_session -> nx_secure_public_cipher_metadata_area,
+ tls_session -> nx_secure_public_cipher_metadata_size,
+ tls_session -> nx_secure_public_auth_metadata_area,
+ tls_session -> nx_secure_public_auth_metadata_size);
/* Set the actual length of the generated key. */
- ecdhe_data->nx_secure_tls_ecdhe_public_key_length = (USHORT)length;
+ ecdhe_data -> nx_secure_tls_ecdhe_public_key_length = (USHORT)length;
if (status != NX_SUCCESS)
{
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_server_handshake.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_server_handshake.c
index 03d4aa8b..60aaaeca 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_server_handshake.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_server_handshake.c
@@ -30,8 +30,8 @@
/* */
/* FUNCTION RELEASE */
/* */
-/* _nx_secure_tls_server_handshake PORTABLE C */
-/* 6.1.4 */
+/* _nx_secure_tls_1_3_server_handshake PORTABLE C */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -59,7 +59,6 @@
/* _nx_secure_tls_generate_keys Generate session keys */
/* _nx_secure_tls_handshake_hash_init Initialize Finished hash */
/* _nx_secure_tls_handshake_hash_update Update Finished hash */
-/* _nx_secure_tls_map_error_to_alert Map internal error to alert */
/* _nx_secure_tls_packet_allocate Allocate internal TLS packet */
/* _nx_secure_tls_process_client_key_exchange */
/* Process ClientKeyExchange */
@@ -69,7 +68,6 @@
/* Process handshake header */
/* _nx_secure_tls_process_remote_certificate */
/* Process server certificate */
-/* _nx_secure_tls_send_alert Send TLS alert */
/* _nx_secure_tls_send_certificate Send TLS certificate */
/* _nx_secure_tls_send_certificate_request */
/* Send TLS CertificateRequest */
@@ -107,6 +105,13 @@
/* support for fragmented TLS */
/* Handshake messages, */
/* resulting in version 6.1.4 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* removed duplicated alert, */
+/* resulting in version 6.1.12 */
+/* 10-31-2022 Yanwu Cai Modified comment(s), */
+/* fixed handling of multiple */
+/* handshake messages, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
#if (NX_SECURE_TLS_TLS_1_3_ENABLED)
@@ -121,9 +126,6 @@ UINT message_length;
NX_PACKET *send_packet;
NX_PACKET_POOL *packet_pool;
UCHAR *packet_start;
-UINT error_number;
-UINT alert_number;
-UINT alert_level;
NX_SECURE_TLS_SERVER_STATE old_server_state;
/* Basic state machine for handshake:
@@ -179,242 +181,177 @@ NX_SECURE_TLS_SERVER_STATE old_server_state;
client) and provide key confirmation and handshake integrity.
*/
-
- /* Save a pointer to the start of our packet for the hash that happens below. */
- packet_start = packet_buffer;
-
- header_bytes = data_length;
-
- status = _nx_secure_tls_process_handshake_header(packet_buffer, &message_type, &header_bytes, &message_length);
-
- if (status != NX_SECURE_TLS_SUCCESS)
+ /* Loop through multiple messages in a single record. This can happen if the remote host
+ packs multiple handshake messages into a single TLS record. */
+ while (data_length > 0)
{
- return(status);
- }
- /* Check for fragmented message. */
- if((message_length + header_bytes) > data_length)
- {
- /* Incomplete message! A single message is fragmented across several records. We need to obtain the next fragment. */
- tls_session -> nx_secure_tls_handshake_record_expected_length = message_length + header_bytes;
-
- tls_session -> nx_secure_tls_handshake_record_fragment_state = NX_SECURE_TLS_HANDSHAKE_RECEIVED_FRAGMENT;
+ /* Save a pointer to the start of our packet for the hash that happens below. */
+ packet_start = packet_buffer;
- return(NX_SECURE_TLS_HANDSHAKE_FRAGMENT_RECEIVED);
- }
+ header_bytes = data_length;
- /* Advance the buffer pointer past the handshake header. */
- packet_buffer += header_bytes;
+ status = _nx_secure_tls_process_handshake_header(packet_buffer, &message_type, &header_bytes, &message_length);
- /* Get reference to the packet pool so we can allocate a packet for all send operations. */
- packet_pool = tls_session -> nx_secure_tls_packet_pool;
-
- /* Process the message itself information from the header. */
- status = NX_SECURE_TLS_SUCCESS;
- switch (message_type)
- {
- case NX_SECURE_TLS_CLIENT_HELLO:
- old_server_state = tls_session -> nx_secure_tls_server_state;
- tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_IDLE;
-
- /* Client is establishing a TLS session with our server. */
- status = _nx_secure_tls_process_clienthello(tls_session, packet_buffer, message_length);
-
- if(status != NX_SUCCESS)
+ if (status != NX_SECURE_TLS_SUCCESS)
{
- break;
- }
-
- if (tls_session -> nx_secure_tls_1_3 == NX_FALSE)
- {
-
- /* Negotiate a version of TLS prior to TLS 1.3. */
- return(NX_SUCCESS);
+ return(status);
}
- if (old_server_state == NX_SECURE_TLS_SERVER_STATE_IDLE)
+ /* Check for fragmented message. */
+ if((message_length + header_bytes) > data_length)
{
-
- /* Initialize the handshake hash - we should have chosen a ciphersuite, so we can
- * initialize the hash state now using the chosen hash. */
- _nx_secure_tls_handshake_hash_init(tls_session);
- }
+ /* Incomplete message! A single message is fragmented across several records. We need to obtain the next fragment. */
+ tls_session -> nx_secure_tls_handshake_record_expected_length = message_length + header_bytes;
- if (tls_session -> nx_secure_tls_server_state != NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY)
- {
- tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_SEND_HELLO;
- }
- break;
-#ifdef NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY
- case NX_SECURE_TLS_CERTIFICATE_MSG:
- /* Client sent certificate message (in response to a request from us. Process it now. */
- status = _nx_secure_tls_process_remote_certificate(tls_session, packet_buffer, message_length, data_length);
+ tls_session -> nx_secure_tls_handshake_record_fragment_state = NX_SECURE_TLS_HANDSHAKE_RECEIVED_FRAGMENT;
- /* If client sends an empty Certificate message, server should abort the handshake with a "certificate_required" alert. */
- if (status == NX_SECURE_TLS_EMPTY_REMOTE_CERTIFICATE_RECEIVED)
- {
- status = NX_SECURE_TLS_CERTIFICATE_REQUIRED;
+ return(NX_SECURE_TLS_HANDSHAKE_FRAGMENT_RECEIVED);
}
- tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_CLIENT_CERTIFICATE;
- break;
- case NX_SECURE_TLS_CERTIFICATE_VERIFY:
- /* Client has responded to a certificate request with a CertificateVerify message. */
- status = _nx_secure_tls_process_certificate_verify(tls_session, packet_buffer, message_length);
+ /* Advance the buffer pointer past the handshake header. */
+ packet_buffer += header_bytes;
- if(status == NX_SUCCESS)
- {
- /* If remote certificate verification was a success, we have received credentials
- from the remote host and may now pass Finished message processing once received. */
- tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE;
- }
+ /* Get reference to the packet pool so we can allocate a packet for all send operations. */
+ packet_pool = tls_session -> nx_secure_tls_packet_pool;
- tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_CERTIFICATE_VERIFY;
- break;
-#endif /* NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY */
- case NX_SECURE_TLS_FINISHED:
+ /* Reduce total length by the size of this message. */
+ data_length -= (message_length + header_bytes);
- /* Save the transcript hash to this point for processing Finished. */
- status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED, NX_TRUE);
- if(status != NX_SUCCESS)
+ /* Process the message itself information from the header. */
+ status = NX_SECURE_TLS_SUCCESS;
+ switch (message_type)
{
- break;
- }
+ case NX_SECURE_TLS_CLIENT_HELLO:
+ old_server_state = tls_session -> nx_secure_tls_server_state;
+ tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_IDLE;
- /* Final handshake message from the client, process it (verify the client handshake hash). */
- status = _nx_secure_tls_process_finished(tls_session, packet_buffer, message_length);
- if(status != NX_SUCCESS)
- {
- break;
- }
+ /* Client is establishing a TLS session with our server. */
+ status = _nx_secure_tls_process_clienthello(tls_session, packet_buffer, message_length);
- /* Save the transcript hash to this point for key generation - Server Finished was processed so save it. */
- status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CLIENT_FINISHED, NX_TRUE);
- if(status != NX_SUCCESS)
- {
- break;
- }
-
- tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_FINISH_HANDSHAKE;
- break;
-/* Invalid message types in tls 1.3.
- case NX_SECURE_TLS_CLIENT_KEY_EXCHANGE:
- case NX_SECURE_TLS_HELLO_VERIFY_REQUEST:
- case NX_SECURE_TLS_HELLO_REQUEST:
- case NX_SECURE_TLS_SERVER_HELLO:
- case NX_SECURE_TLS_SERVER_KEY_EXCHANGE:
- case NX_SECURE_TLS_CERTIFICATE_REQUEST:
- case NX_SECURE_TLS_SERVER_HELLO_DONE:
- case NX_SECURE_TLS_CERTIFICATE_URL:
- case NX_SECURE_TLS_CERTIFICATE_STATUS:
-*/
- default:
- /* The message received was not a valid TLS server handshake message, send alert and return. */
- status = NX_SECURE_TLS_HANDSHAKE_FAILURE;
- break;
- }
-
- /* Check for errors in processing messages. */
- if (status != NX_SECURE_TLS_SUCCESS)
- {
- /* If we encountered an error in message processing set the state to the error condition. */
- tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_ERROR;
- }
- else
- {
- /* Hash this handshake message. We do not hash HelloRequest messages, but since only the server will send them,
- we do not worry about them here because these are only messages received from the client at this point.
- Hashes include the handshake layer header but not the record layer header. */
- _nx_secure_tls_handshake_hash_update(tls_session, packet_start, (UINT)(message_length + header_bytes));
- if((message_type == NX_SECURE_TLS_CLIENT_HELLO) && (tls_session -> nx_secure_tls_server_state != NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY))
- {
- /* Save the transcript hash for ClientHello - ClientHello was processed so we now have a ciphersuite and know what
- our hash method is. */
- status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CLIENTHELLO, NX_TRUE);
if(status != NX_SUCCESS)
{
- return status;
+ break;
}
- }
- }
- /* Now take any actions based on state set in the message processing. */
- switch (tls_session -> nx_secure_tls_server_state)
- {
- case NX_SECURE_TLS_SERVER_STATE_SEND_HELLO:
- /* We have received and processed a client hello. Now respond to the client appropriately. */
- status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
+ if (tls_session -> nx_secure_tls_1_3 == NX_FALSE)
+ {
- if (status != NX_SUCCESS)
- {
- break;
- }
+ /* Negotiate a version of TLS prior to TLS 1.3. */
+ return(NX_SUCCESS);
+ }
- status = _nx_secure_tls_send_serverhello(tls_session, send_packet);
+ if (old_server_state == NX_SECURE_TLS_SERVER_STATE_IDLE)
+ {
+
+ /* Initialize the handshake hash - we should have chosen a ciphersuite, so we can
+ * initialize the hash state now using the chosen hash. */
+ _nx_secure_tls_handshake_hash_init(tls_session);
+ }
- if (status != NX_SUCCESS)
- {
+ if (tls_session -> nx_secure_tls_server_state != NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY)
+ {
+ tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_SEND_HELLO;
+ }
break;
- }
+#ifdef NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY
+ case NX_SECURE_TLS_CERTIFICATE_MSG:
+ /* Client sent certificate message (in response to a request from us. Process it now. */
+ status = _nx_secure_tls_process_remote_certificate(tls_session, packet_buffer, message_length, data_length);
- status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_HELLO, wait_option);
+ /* If client sends an empty Certificate message, server should abort the handshake with a "certificate_required" alert. */
+ if (status == NX_SECURE_TLS_EMPTY_REMOTE_CERTIFICATE_RECEIVED)
+ {
+ status = NX_SECURE_TLS_CERTIFICATE_REQUIRED;
+ }
- if (status != NX_SUCCESS)
- {
+ tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_CLIENT_CERTIFICATE;
break;
- }
+ case NX_SECURE_TLS_CERTIFICATE_VERIFY:
+ /* Client has responded to a certificate request with a CertificateVerify message. */
+ status = _nx_secure_tls_process_certificate_verify(tls_session, packet_buffer, message_length);
+ if(status == NX_SUCCESS)
+ {
+ /* If remote certificate verification was a success, we have received credentials
+ from the remote host and may now pass Finished message processing once received. */
+ tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE;
+ }
- /* Save the transcript hash to this point for key generation - ServerHello was sent so use it. */
- status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVERHELLO, NX_TRUE);
- if(status != NX_SUCCESS)
- {
+ tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_CERTIFICATE_VERIFY;
break;
- }
-
- NX_ASSERT(tls_session -> nx_secure_tls_session_ciphersuite != NX_NULL);
-
+#endif /* NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY */
+ case NX_SECURE_TLS_FINISHED:
- /* In TLS 1.3, we now have enough information to generate the handshake encryption keys and start encrypting messages. */
- /* Generate TLS 1.3 keys and secrets for the handshake. */
- status = _nx_secure_tls_1_3_generate_handshake_keys(tls_session);
- if(status != NX_SUCCESS)
- {
- break;
- }
+ /* Save the transcript hash to this point for processing Finished. */
+ status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED, NX_TRUE);
+ if(status != NX_SUCCESS)
+ {
+ break;
+ }
- /* Now turn on encryption. We have generated the handshake keys so the rest of the handshake is encrypted. */
- tls_session -> nx_secure_tls_local_session_active = 1;
- tls_session -> nx_secure_tls_remote_session_active = 1;
+ /* Final handshake message from the client, process it (verify the client handshake hash). */
+ status = _nx_secure_tls_process_finished(tls_session, packet_buffer, message_length);
+ if(status != NX_SUCCESS)
+ {
+ break;
+ }
- /* Send encrypted server extensions (if any) here. */
-
- /* We have now started the encrypted TLS 1.3 handshake. Send encrypted extensions now. */
- status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
+ /* Save the transcript hash to this point for key generation - Server Finished was processed so save it. */
+ status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CLIENT_FINISHED, NX_TRUE);
+ if(status != NX_SUCCESS)
+ {
+ break;
+ }
- if (status != NX_SUCCESS)
- {
+ tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_FINISH_HANDSHAKE;
+ break;
+/* Invalid message types in tls 1.3.
+ case NX_SECURE_TLS_CLIENT_KEY_EXCHANGE:
+ case NX_SECURE_TLS_HELLO_VERIFY_REQUEST:
+ case NX_SECURE_TLS_HELLO_REQUEST:
+ case NX_SECURE_TLS_SERVER_HELLO:
+ case NX_SECURE_TLS_SERVER_KEY_EXCHANGE:
+ case NX_SECURE_TLS_CERTIFICATE_REQUEST:
+ case NX_SECURE_TLS_SERVER_HELLO_DONE:
+ case NX_SECURE_TLS_CERTIFICATE_URL:
+ case NX_SECURE_TLS_CERTIFICATE_STATUS:
+*/
+ default:
+ /* The message received was not a valid TLS server handshake message, send alert and return. */
+ status = NX_SECURE_TLS_HANDSHAKE_FAILURE;
break;
}
- status = _nx_secure_tls_send_encrypted_extensions(tls_session, send_packet);
-
- if (status != NX_SUCCESS)
+ /* Check for errors in processing messages. */
+ if (status != NX_SECURE_TLS_SUCCESS)
{
- break;
+ /* If we encountered an error in message processing set the state to the error condition. */
+ tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_ERROR;
}
-
- status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_ENCRYPTED_EXTENSIONS, wait_option);
- if (status != NX_SUCCESS)
+ else
{
- break;
+ /* Hash this handshake message. We do not hash HelloRequest messages, but since only the server will send them,
+ we do not worry about them here because these are only messages received from the client at this point.
+ Hashes include the handshake layer header but not the record layer header. */
+ _nx_secure_tls_handshake_hash_update(tls_session, packet_start, (UINT)(message_length + header_bytes));
+ if((message_type == NX_SECURE_TLS_CLIENT_HELLO) && (tls_session -> nx_secure_tls_server_state != NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY))
+ {
+ /* Save the transcript hash for ClientHello - ClientHello was processed so we now have a ciphersuite and know what
+ our hash method is. */
+ status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CLIENTHELLO, NX_TRUE);
+ if(status != NX_SUCCESS)
+ {
+ return status;
+ }
+ }
}
-#ifdef NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY
- /* Application has requested that we request and verify the remote Client certificate. */
- if (tls_session -> nx_secure_tls_verify_client_certificate)
+ /* Now take any actions based on state set in the message processing. */
+ switch (tls_session -> nx_secure_tls_server_state)
{
- /* Allocate a packet for our certificate request message. */
+ case NX_SECURE_TLS_SERVER_STATE_SEND_HELLO:
+ /* We have received and processed a client hello. Now respond to the client appropriately. */
status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
if (status != NX_SUCCESS)
@@ -422,52 +359,46 @@ NX_SECURE_TLS_SERVER_STATE old_server_state;
break;
}
- /* Populate our packet with the desired message (CertificateRequest). */
- status = _nx_secure_tls_send_certificate_request(tls_session, send_packet);
- NX_ASSERT(status == NX_SUCCESS);
+ status = _nx_secure_tls_send_serverhello(tls_session, send_packet);
- status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_REQUEST, wait_option);
if (status != NX_SUCCESS)
{
break;
}
- }
- else
-#endif
- {
- /* Server is not expecting credentials, so indicate that we have received the client's credentials
- to pass Finished processing. */
- tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE;
- }
-#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES
- /* For PSK ciphersuites, don't send the certificate message. */
- if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm != NX_CRYPTO_KEY_EXCHANGE_PSK &&
- tls_session->nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_data_size == 0)
- {
-#endif /* NX_SECURE_ENABLE_PSK_CIPHERSUITES */
- status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
+ status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_HELLO, wait_option);
if (status != NX_SUCCESS)
{
break;
}
- _nx_secure_tls_send_certificate(tls_session, send_packet, wait_option);
- status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_MSG, wait_option);
- if (status != NX_SUCCESS)
+
+ /* Save the transcript hash to this point for key generation - ServerHello was sent so use it. */
+ status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVERHELLO, NX_TRUE);
+ if(status != NX_SUCCESS)
{
break;
}
- /* Save the transcript hash up to the certificate for the CertificateVerify (next message to send). */
- status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CERTIFICATE, NX_TRUE);
+ NX_ASSERT(tls_session -> nx_secure_tls_session_ciphersuite != NX_NULL);
+
+
+ /* In TLS 1.3, we now have enough information to generate the handshake encryption keys and start encrypting messages. */
+ /* Generate TLS 1.3 keys and secrets for the handshake. */
+ status = _nx_secure_tls_1_3_generate_handshake_keys(tls_session);
if(status != NX_SUCCESS)
{
break;
}
+ /* Now turn on encryption. We have generated the handshake keys so the rest of the handshake is encrypted. */
+ tls_session -> nx_secure_tls_local_session_active = 1;
+ tls_session -> nx_secure_tls_remote_session_active = 1;
+ /* Send encrypted server extensions (if any) here. */
+
+ /* We have now started the encrypted TLS 1.3 handshake. Send encrypted extensions now. */
status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
if (status != NX_SUCCESS)
@@ -475,170 +406,228 @@ NX_SECURE_TLS_SERVER_STATE old_server_state;
break;
}
- _nx_secure_tls_send_certificate_verify(tls_session, send_packet);
+ status = _nx_secure_tls_send_encrypted_extensions(tls_session, send_packet);
+ if (status != NX_SUCCESS)
+ {
+ break;
+ }
- status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_VERIFY, wait_option);
+ status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_ENCRYPTED_EXTENSIONS, wait_option);
if (status != NX_SUCCESS)
{
break;
}
+#ifdef NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY
+ /* Application has requested that we request and verify the remote Client certificate. */
+ if (tls_session -> nx_secure_tls_verify_client_certificate)
+ {
+ /* Allocate a packet for our certificate request message. */
+ status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
+
+ if (status != NX_SUCCESS)
+ {
+ break;
+ }
+
+ /* Populate our packet with the desired message (CertificateRequest). */
+ status = _nx_secure_tls_send_certificate_request(tls_session, send_packet);
+ NX_ASSERT(status == NX_SUCCESS);
+
+ status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_REQUEST, wait_option);
+ if (status != NX_SUCCESS)
+ {
+ break;
+ }
+ }
+ else
+#endif
+ {
+ /* Server is not expecting credentials, so indicate that we have received the client's credentials
+ to pass Finished processing. */
+ tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE;
+ }
#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES
- }
-#endif
+ /* For PSK ciphersuites, don't send the certificate message. */
+ if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm != NX_CRYPTO_KEY_EXCHANGE_PSK &&
+ tls_session->nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_data_size == 0)
+ {
+#endif /* NX_SECURE_ENABLE_PSK_CIPHERSUITES */
+ status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
- /* Save the transcript hash to this point for generating Finished. */
- status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED, NX_TRUE);
- if(status != NX_SUCCESS)
- {
- break;
- }
+ if (status != NX_SUCCESS)
+ {
+ break;
+ }
- /* We have completed sending everything from the server side and generated our session keys, now send the Finished. */
- status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
- if (status != NX_SUCCESS)
- {
- break;
- }
+ _nx_secure_tls_send_certificate(tls_session, send_packet, wait_option);
+ status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_MSG, wait_option);
+ if (status != NX_SUCCESS)
+ {
+ break;
+ }
- /* Populate the packet with our Finished Message. */
- _nx_secure_tls_send_finished(tls_session, send_packet);
- status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_FINISHED, wait_option);
- if(status != NX_SUCCESS)
- {
- break;
- }
+ /* Save the transcript hash up to the certificate for the CertificateVerify (next message to send). */
+ status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CERTIFICATE, NX_TRUE);
+ if(status != NX_SUCCESS)
+ {
+ break;
+ }
- /* Save the finished message now - overwrite previous hash. */
- status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED, NX_TRUE);
- if(status != NX_SUCCESS)
- {
- break;
- }
- /* Re-generate TLS 1.3 keys and secrets including the Server Finished message for the application data session. */
- status = _nx_secure_tls_1_3_generate_session_keys(tls_session);
- if(status != NX_SUCCESS)
- {
- break;
- }
+ status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
- /* In TLS 1.3, the server sends everything in a single flight - ServerHello through Finished, so
- * no need to go into the other states. */
+ if (status != NX_SUCCESS)
+ {
+ break;
+ }
- /* Now switch to the session keys for our local session since we have sent the Server Finished message. */
- status = _nx_secure_tls_1_3_session_keys_set(tls_session, NX_SECURE_TLS_KEY_SET_LOCAL);
- if(status != NX_SUCCESS)
- {
- break;
- }
+ _nx_secure_tls_send_certificate_verify(tls_session, send_packet);
- /* We still need to process the Client responses - certificate (if needed), and Finished. */
- tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HELLO_SENT;
- break;
- case NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY:
- /* We have received and processed a client hello retry requst. Now respond to the client appropriately. */
- status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
+ status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_VERIFY, wait_option);
+ if (status != NX_SUCCESS)
+ {
+ break;
+ }
- if (status != NX_SUCCESS)
- {
- break;
- }
- status = _nx_secure_tls_send_serverhello(tls_session, send_packet);
+#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES
+ }
+#endif
- if (status != NX_SUCCESS)
- {
- break;
- }
+ /* Save the transcript hash to this point for generating Finished. */
+ status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED, NX_TRUE);
+ if(status != NX_SUCCESS)
+ {
+ break;
+ }
+
+ /* We have completed sending everything from the server side and generated our session keys, now send the Finished. */
+ status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
+ if (status != NX_SUCCESS)
+ {
+ break;
+ }
+
+ /* Populate the packet with our Finished Message. */
+ _nx_secure_tls_send_finished(tls_session, send_packet);
+ status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_FINISHED, wait_option);
+ if(status != NX_SUCCESS)
+ {
+ break;
+ }
+
+ /* Save the finished message now - overwrite previous hash. */
+ status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED, NX_TRUE);
+ if(status != NX_SUCCESS)
+ {
+ break;
+ }
+
+ /* Re-generate TLS 1.3 keys and secrets including the Server Finished message for the application data session. */
+ status = _nx_secure_tls_1_3_generate_session_keys(tls_session);
+ if(status != NX_SUCCESS)
+ {
+ break;
+ }
+
+ /* In TLS 1.3, the server sends everything in a single flight - ServerHello through Finished, so
+ * no need to go into the other states. */
+
+ /* Now switch to the session keys for our local session since we have sent the Server Finished message. */
+ status = _nx_secure_tls_1_3_session_keys_set(tls_session, NX_SECURE_TLS_KEY_SET_LOCAL);
+ if(status != NX_SUCCESS)
+ {
+ break;
+ }
+
+ /* We still need to process the Client responses - certificate (if needed), and Finished. */
+ tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HELLO_SENT;
- status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_HELLO, wait_option);
- break;
- case NX_SECURE_TLS_SERVER_STATE_CLIENT_CERTIFICATE:
-
- /* Save the transcript hash up to the certificate for the CertificateVerify (next message to send). */
- status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CERTIFICATE, NX_TRUE);
- break;
- case NX_SECURE_TLS_SERVER_STATE_CERTIFICATE_VERIFY:
- /* We processed the certificate above, do nothing. */
- break;
- case NX_SECURE_TLS_SERVER_STATE_FINISH_HANDSHAKE:
-
- /* Now switch to the session keys for our remote session since we have processed the Finished from the Client. */
- status = _nx_secure_tls_1_3_session_keys_set(tls_session, NX_SECURE_TLS_KEY_SET_REMOTE);
- if(status != NX_SUCCESS)
- {
break;
- }
+ case NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY:
+ /* We have received and processed a client hello retry requst. Now respond to the client appropriately. */
+ status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
- /* Post-Auth server messages (if any) are sent here. */
+ if (status != NX_SUCCESS)
+ {
+ break;
+ }
- /* For session resumption, send a NewSessionTicket message to allow for resumption PSK to be generated. */
- status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
- if (status != NX_SUCCESS)
- {
+ status = _nx_secure_tls_send_serverhello(tls_session, send_packet);
+
+ if (status != NX_SUCCESS)
+ {
+ break;
+ }
+
+ status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_HELLO, wait_option);
break;
- }
+ case NX_SECURE_TLS_SERVER_STATE_CLIENT_CERTIFICATE:
- /* Populate the packet with our NewSessionTicket Message. */
- status = _nx_secure_tls_send_newsessionticket(tls_session, send_packet);
- status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_NEW_SESSION_TICKET, wait_option);
- if(status != NX_SUCCESS)
- {
+ /* Save the transcript hash up to the certificate for the CertificateVerify (next message to send). */
+ status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CERTIFICATE, NX_TRUE);
break;
- }
+ case NX_SECURE_TLS_SERVER_STATE_CERTIFICATE_VERIFY:
+ /* We processed the certificate above, do nothing. */
+ break;
+ case NX_SECURE_TLS_SERVER_STATE_FINISH_HANDSHAKE:
- /* If we get here, the Client Finished was processed without errors and the handshake is complete. */
- tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HANDSHAKE_FINISHED;
- break;
-/* case NX_SECURE_TLS_SERVER_STATE_KEY_EXCHANGE: // tls 1.3: No CLIENT_KEY_EXCHANGE message!
- */
- default: /* NX_SECURE_TLS_SERVER_STATE_ERROR */
- /* Default is to break out of the switch because either we encountered an error or
- we are in an invalid state. DO NOT change the value of "status" here because
- we need its value in the alert processing below. NOTE: we should never
- get to this branch with status == NX_SUCCESS because the state will only
- be set to NX_SECURE_TLS_SERVER_STATE_ERROR if status indicates an error. */
- NX_ASSERT(status != NX_SUCCESS);
- break;
- }
-
-
- /* If we have an error at this point, we have experienced a problem in processing or sending
- handshake messages, which is some type of internal issue. Send an alert
- back to the remote host indicating the error. */
- if (status != NX_SUCCESS)
- {
- /* Get our alert number and level from our status. */
- error_number = status;
- _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level);
+ /* Now switch to the session keys for our remote session since we have processed the Finished from the Client. */
+ status = _nx_secure_tls_1_3_session_keys_set(tls_session, NX_SECURE_TLS_KEY_SET_REMOTE);
+ if(status != NX_SUCCESS)
+ {
+ break;
+ }
- /* Release the protection before suspending on nx_packet_allocate. */
- tx_mutex_put(&_nx_secure_tls_protection);
+ /* Post-Auth server messages (if any) are sent here. */
- status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option);
+ /* For session resumption, send a NewSessionTicket message to allow for resumption PSK to be generated. */
+ status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option);
+ if (status != NX_SUCCESS)
+ {
+ break;
+ }
+
+ /* Populate the packet with our NewSessionTicket Message. */
+ status = _nx_secure_tls_send_newsessionticket(tls_session, send_packet);
+ status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_NEW_SESSION_TICKET, wait_option);
+ if(status != NX_SUCCESS)
+ {
+ break;
+ }
- /* Get the protection after nx_packet_allocate. */
- tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
+ /* If we get here, the Client Finished was processed without errors and the handshake is complete. */
+ tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HANDSHAKE_FINISHED;
+ break;
+/* case NX_SECURE_TLS_SERVER_STATE_KEY_EXCHANGE: // tls 1.3: No CLIENT_KEY_EXCHANGE message!
+ */
+ default: /* NX_SECURE_TLS_SERVER_STATE_ERROR */
+ /* Default is to break out of the switch because either we encountered an error or
+ we are in an invalid state. DO NOT change the value of "status" here because
+ we need its value in the alert processing below. NOTE: we should never
+ get to this branch with status == NX_SUCCESS because the state will only
+ be set to NX_SECURE_TLS_SERVER_STATE_ERROR if status indicates an error. */
+ NX_ASSERT(status != NX_SUCCESS);
+ break;
+ }
- if (status == NX_SUCCESS)
+ /* If we have an error at this point, we have experienced a problem in sending
+ handshake messages, which is some type of internal issue. */
+ if (status != NX_SUCCESS)
{
- _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level);
- status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option);
- if (status != NX_SECURE_TLS_SUCCESS)
- {
- nx_secure_tls_packet_release(send_packet);
- }
+ return(status);
}
- return(error_number);
- }
+ /* Advance the buffer pointer past the message. */
+ packet_buffer += message_length;
+ } /* End while. */
- return(status);
+ return(NX_SUCCESS);
#else /* TLS Server disabled. */
/* We don't use the parameters since this is an error case. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_client_handshake.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_client_handshake.c
index 58c7b97b..46832915 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_client_handshake.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_client_handshake.c
@@ -30,7 +30,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_secure_tls_client_handshake PORTABLE C */
-/* 6.1.5 */
+/* 6.1.12 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -60,7 +60,6 @@
/* _nx_secure_tls_generate_premaster_secret */
/* Generate premaster secret */
/* _nx_secure_tls_handshake_hash_update Update Finished hash */
-/* _nx_secure_tls_map_error_to_alert Map internal error to alert */
/* _nx_secure_tls_packet_allocate Allocate internal TLS packet */
/* _nx_secure_tls_process_certificate_request */
/* Process certificate request */
@@ -74,7 +73,6 @@
/* _nx_secure_tls_process_serverhello Process ServerHello */
/* _nx_secure_tls_remote_certificate_free_all */
/* Free all remote certificates */
-/* _nx_secure_tls_send_alert Send TLS alert */
/* _nx_secure_tls_send_certificate Send TLS certificate */
/* _nx_secure_tls_send_certificate_verify */
/* Send certificate verify */
@@ -118,6 +116,9 @@
/* 03-02-2021 Timothy Stapko Modified comment(s), */
/* fixed compiler warnings, */
/* resulting in version 6.1.5 */
+/* 07-29-2022 Yuxin Zhou Modified comment(s), */
+/* removed duplicated alert, */
+/* resulting in version 6.1.12 */
/* */
/**************************************************************************/
UINT _nx_secure_tls_client_handshake(NX_SECURE_TLS_SESSION *tls_session, UCHAR *packet_buffer,
@@ -133,9 +134,6 @@ UINT packet_buffer_length = data_length;
UCHAR *packet_start;
NX_PACKET *send_packet = NX_NULL;
NX_PACKET_POOL *packet_pool;
-UINT error_number;
-UINT alert_number;
-UINT alert_level;
const NX_CRYPTO_METHOD
*method_ptr = NX_NULL;
@@ -311,29 +309,8 @@ const NX_CRYPTO_METHOD
/* Check for errors in processing messages. */
if (status != NX_SECURE_TLS_SUCCESS)
{
- /* Get our alert number and level from our status. */
- error_number = status;
- _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level);
- /* Release the protection before suspending on nx_packet_allocate. */
- tx_mutex_put(&_nx_secure_tls_protection);
-
- status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option);
-
- /* Get the protection after nx_packet_allocate. */
- tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
-
- if (status == NX_SUCCESS)
- {
- _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level);
- status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option);
-
- if (status != NX_SUCCESS)
- {
- nx_secure_tls_packet_release(send_packet);
- }
- }
- return(error_number);
+ return(status);
}
/* Now take any actions based on state set in the message processing. */
@@ -594,34 +571,11 @@ const NX_CRYPTO_METHOD
}
/* If we have an error at this point, we have experienced a problem in sending
- handshake messages, which is some type of internal issue. Send an alert
- back to the remote host indicating the error. */
+ handshake messages, which is some type of internal issue. */
if (status != NX_SUCCESS)
{
- /* Get our alert number and level from our status. */
- error_number = status;
- _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level);
- /* Release the protection before suspending on nx_packet_allocate. */
- tx_mutex_put(&_nx_secure_tls_protection);
-
- status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option);
-
- /* Get the protection after nx_packet_allocate. */
- tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER);
-
- if (status == NX_SUCCESS)
- {
- _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level);
- status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option);
-
- if (status != NX_SUCCESS)
- {
- nx_secure_tls_packet_release(send_packet);
- }
- }
-
- return(error_number);
+ return(status);
}
/* Advance the buffer pointer past the message. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_ecc_generate_keys.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_ecc_generate_keys.c
index 9472a06e..5d2e1e23 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_ecc_generate_keys.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_ecc_generate_keys.c
@@ -47,7 +47,7 @@ static const UCHAR _NX_CRYPTO_DER_OID_SHA_512[] = {0x30, 0x51, 0x30, 0x0d,
/* FUNCTION RELEASE */
/* */
/* _nx_secure_tls_ecc_generate_keys PORTABLE C */
-/* 6.1.11 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -68,12 +68,23 @@ static const UCHAR _NX_CRYPTO_DER_OID_SHA_512[] = {0x30, 0x51, 0x30, 0x0d,
/* */
/* INPUT */
/* */
-/* tls_session TLS control block */
+/* ciphersuite Selected cipher suite */
+/* protocol_version Selected TLS version */
+/* tls_1_3 Whether TLS 1.3 is chosen */
+/* tls_crypto_table TLS crypto methods */
+/* tls_handshake_hash Metadata for handshake hash */
+/* tls_ecc_curves ECC curves */
+/* tls_key_material TLS key material */
+/* tls_credentials TLS credentials */
/* ecc_named_curve IANA ECC curve identifier */
/* sign_key True/False generate signature */
/* public_key Signed ECC public key */
/* public_key_size Size of public key */
/* ecc_data ECC data (incl. private key) */
+/* public_cipher_metadata Metadata for public cipher */
+/* public_cipher_metadata_size Size of public cipher metadata*/
+/* public_auth_metadata Metadata for public auth */
+/* public_auth_metadata_size Size of public auth metadata */
/* */
/* OUTPUT */
/* */
@@ -99,10 +110,18 @@ static const UCHAR _NX_CRYPTO_DER_OID_SHA_512[] = {0x30, 0x51, 0x30, 0x0d,
/* 04-25-2022 Yuxin Zhou Modified comment(s), removed */
/* internal unreachable logic, */
/* resulting in version 6.1.11 */
+/* 10-31-2022 Yanwu Cai Modified comment(s), */
+/* updated parameters list, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
-UINT _nx_secure_tls_ecc_generate_keys(NX_SECURE_TLS_SESSION *tls_session, UINT ecc_named_curve, USHORT sign_key,
- UCHAR *public_key, UINT *public_key_size, NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecc_data)
+UINT _nx_secure_tls_ecc_generate_keys(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, UCHAR tls_1_3,
+ NX_SECURE_TLS_CRYPTO *tls_crypto_table, NX_SECURE_TLS_HANDSHAKE_HASH *tls_handshake_hash,
+ NX_SECURE_TLS_ECC *tls_ecc_curves, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material,
+ NX_SECURE_TLS_CREDENTIALS *tls_credentials, UINT ecc_named_curve, USHORT sign_key,
+ UCHAR *public_key, UINT *public_key_size, NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecc_data,
+ VOID *public_cipher_metadata, ULONG public_cipher_metadata_size,
+ VOID *public_auth_metadata, ULONG public_auth_metadata_size)
{
UINT length;
UINT output_size;
@@ -125,24 +144,27 @@ NX_SECURE_EC_PRIVATE_KEY *ec_privkey;
NX_SECURE_EC_PUBLIC_KEY *ec_pubkey;
USHORT signature_algorithm_id;
+#if !(NX_SECURE_TLS_TLS_1_0_ENABLED) && !(NX_SECURE_TLS_TLS_1_1_ENABLED)
+ NX_PARAMETER_NOT_USED(protocol_version);
+#endif
+
+#if !(NX_SECURE_TLS_TLS_1_3_ENABLED) || (!(NX_SECURE_TLS_TLS_1_0_ENABLED) && !(NX_SECURE_TLS_TLS_1_1_ENABLED))
+ NX_PARAMETER_NOT_USED(tls_1_3);
+ NX_PARAMETER_NOT_USED(tls_crypto_table);
+#endif
+
#if (NX_SECURE_TLS_TLS_1_3_ENABLED)
- if(tls_session->nx_secure_tls_1_3)
+ if(tls_1_3)
{
- ecdhe_method = tls_session->nx_secure_tls_crypto_table->nx_secure_tls_ecdhe_method;
+ ecdhe_method = tls_crypto_table -> nx_secure_tls_ecdhe_method;
}
else
#endif
{
- if (tls_session -> nx_secure_tls_session_ciphersuite == NX_NULL)
- {
-
- /* Likely internal error since at this point ciphersuite negotiation was theoretically completed. */
- return(NX_SECURE_TLS_UNKNOWN_CIPHERSUITE);
- }
/* Generate ECDHE key pair using ECDHE crypto method. */
- ecdhe_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher;
+ ecdhe_method = ciphersuite -> nx_secure_tls_public_cipher;
}
/* Make sure we have a method to use. */
@@ -152,10 +174,10 @@ USHORT signature_algorithm_id;
}
/* Set the curve we are using. */
- ecc_data->nx_secure_tls_ecdhe_named_curve = ecc_named_curve;
+ ecc_data -> nx_secure_tls_ecdhe_named_curve = ecc_named_curve;
/* Find out which named curve the we are using. */
- status = _nx_secure_tls_find_curve_method(tls_session, (USHORT)ecc_named_curve, &curve_method, NX_NULL);
+ status = _nx_secure_tls_find_curve_method(tls_ecc_curves, (USHORT)ecc_named_curve, &curve_method, NX_NULL);
if(status != NX_SUCCESS)
{
return(status);
@@ -167,8 +189,8 @@ USHORT signature_algorithm_id;
NX_NULL,
0,
&handler,
- tls_session -> nx_secure_public_cipher_metadata_area,
- tls_session -> nx_secure_public_cipher_metadata_size);
+ public_cipher_metadata,
+ public_cipher_metadata_size);
if(status != NX_CRYPTO_SUCCESS)
{
return(status);
@@ -179,8 +201,8 @@ USHORT signature_algorithm_id;
(NX_CRYPTO_METHOD*)ecdhe_method, NX_NULL, 0,
(UCHAR *)curve_method, sizeof(NX_CRYPTO_METHOD *), NX_NULL,
NX_NULL, 0,
- tls_session -> nx_secure_public_cipher_metadata_area,
- tls_session -> nx_secure_public_cipher_metadata_size,
+ public_cipher_metadata,
+ public_cipher_metadata_size,
NX_NULL, NX_NULL);
if (status != NX_CRYPTO_SUCCESS)
{
@@ -194,7 +216,7 @@ USHORT signature_algorithm_id;
*public_key_size = 0;
#if (NX_SECURE_TLS_TLS_1_3_ENABLED)
- if(!tls_session->nx_secure_tls_1_3)
+ if(!tls_1_3)
#endif
{
/* ECCurveType: named_curve (3). */
@@ -210,7 +232,7 @@ USHORT signature_algorithm_id;
/* Generate the key pair and output the public key. */
#if (NX_SECURE_TLS_TLS_1_3_ENABLED)
- if(tls_session->nx_secure_tls_1_3)
+ if(tls_1_3)
{
extended_output.nx_crypto_extended_output_data = &public_key[length];
extended_output.nx_crypto_extended_output_length_in_byte = output_size - length;
@@ -227,8 +249,8 @@ USHORT signature_algorithm_id;
NX_NULL, 0, NX_NULL,
(UCHAR *)&extended_output,
sizeof(extended_output),
- tls_session -> nx_secure_public_cipher_metadata_area,
- tls_session -> nx_secure_public_cipher_metadata_size,
+ public_cipher_metadata,
+ public_cipher_metadata_size,
NX_NULL, NX_NULL);
if (status != NX_CRYPTO_SUCCESS)
{
@@ -236,7 +258,7 @@ USHORT signature_algorithm_id;
}
#if (NX_SECURE_TLS_TLS_1_3_ENABLED)
- if(!tls_session->nx_secure_tls_1_3)
+ if(!tls_1_3)
#endif
{
/* Put the length into the buffer before the key data. */
@@ -257,8 +279,8 @@ USHORT signature_algorithm_id;
NX_NULL, 0, NX_NULL,
(UCHAR *)&extended_output,
sizeof(extended_output),
- tls_session -> nx_secure_public_cipher_metadata_area,
- tls_session -> nx_secure_public_cipher_metadata_size,
+ public_cipher_metadata,
+ public_cipher_metadata_size,
NX_NULL, NX_NULL);
if (status != NX_CRYPTO_SUCCESS)
{
@@ -271,7 +293,7 @@ USHORT signature_algorithm_id;
/* Cleanup the ECC crypto state. */
if (ecdhe_method -> nx_crypto_cleanup)
{
- status = ecdhe_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_cipher_metadata_area);
+ status = ecdhe_method -> nx_crypto_cleanup(public_cipher_metadata);
if(status != NX_CRYPTO_SUCCESS)
{
return(status);
@@ -282,14 +304,14 @@ USHORT signature_algorithm_id;
if(sign_key == NX_TRUE)
{
/* Get the local certificate. */
- if (tls_session -> nx_secure_tls_credentials.nx_secure_tls_active_certificate != NX_NULL)
+ if (tls_credentials -> nx_secure_tls_active_certificate != NX_NULL)
{
- certificate = tls_session -> nx_secure_tls_credentials.nx_secure_tls_active_certificate;
+ certificate = tls_credentials -> nx_secure_tls_active_certificate;
}
else
{
/* Get reference to local device certificate. NX_NULL is passed for name to get default entry. */
- status = _nx_secure_x509_local_device_certificate_get(&tls_session -> nx_secure_tls_credentials.nx_secure_tls_certificate_store,
+ status = _nx_secure_x509_local_device_certificate_get(&tls_credentials -> nx_secure_tls_certificate_store,
NX_NULL, &certificate);
if (status != NX_SUCCESS)
{
@@ -321,18 +343,18 @@ USHORT signature_algorithm_id;
#if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED)
#ifdef NX_SECURE_ENABLE_DTLS
if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA &&
- (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0))
+ (protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
+ protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 ||
+ protocol_version == NX_SECURE_DTLS_VERSION_1_0))
#else
if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA &&
- (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1))
+ (protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
+ protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1))
#endif /* NX_SECURE_ENABLE_DTLS */
{
/* TLS 1.0 and TLS 1.1 use MD5 + SHA1 hash for RSA signatures. */
- hash_method = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_md5_method;
+ hash_method = tls_crypto_table -> nx_secure_tls_handshake_hash_md5_method;
}
else
#endif /* NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED */
@@ -350,8 +372,8 @@ USHORT signature_algorithm_id;
NX_NULL,
0,
&handler,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size);
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size);
if(status != NX_CRYPTO_SUCCESS)
{
@@ -371,8 +393,8 @@ USHORT signature_algorithm_id;
NX_NULL,
NX_NULL,
0,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size,
NX_NULL,
NX_NULL);
@@ -391,13 +413,13 @@ USHORT signature_algorithm_id;
(NX_CRYPTO_METHOD*)hash_method,
NX_NULL,
0,
- tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random,
+ tls_key_material -> nx_secure_tls_client_random,
32,
NX_NULL,
NX_NULL,
0,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size,
NX_NULL,
NX_NULL);
@@ -411,13 +433,13 @@ USHORT signature_algorithm_id;
(NX_CRYPTO_METHOD*)hash_method,
NX_NULL,
0,
- tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random,
+ tls_key_material -> nx_secure_tls_server_random,
32,
NX_NULL,
NX_NULL,
0,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size,
NX_NULL,
NX_NULL);
@@ -436,8 +458,8 @@ USHORT signature_algorithm_id;
NX_NULL,
NX_NULL,
0,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size,
NX_NULL,
NX_NULL);
@@ -456,8 +478,8 @@ USHORT signature_algorithm_id;
NX_NULL,
hash,
hash_length,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size,
NX_NULL,
NX_NULL);
@@ -468,7 +490,7 @@ USHORT signature_algorithm_id;
if (hash_method -> nx_crypto_cleanup)
{
- status = hash_method -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch);
+ status = hash_method -> nx_crypto_cleanup(tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch);
if(status != NX_CRYPTO_SUCCESS)
{
@@ -480,16 +502,16 @@ USHORT signature_algorithm_id;
#if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED)
#ifdef NX_SECURE_ENABLE_DTLS
if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA &&
- (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0))
+ (protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
+ protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 ||
+ protocol_version == NX_SECURE_DTLS_VERSION_1_0))
#else
if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA &&
- (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1))
+ (protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
+ protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1))
#endif /* NX_SECURE_ENABLE_DTLS */
{
- hash_method = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_sha1_method;;
+ hash_method = tls_crypto_table -> nx_secure_tls_handshake_hash_sha1_method;;
/* Calculate the hash: SHA(ClientHello.random + ServerHello.random +
ServerKeyExchange.params); */
@@ -499,8 +521,8 @@ USHORT signature_algorithm_id;
NX_NULL,
0,
&handler,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size);
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size);
if(status != NX_CRYPTO_SUCCESS)
{
@@ -520,8 +542,8 @@ USHORT signature_algorithm_id;
NX_NULL,
NX_NULL,
0,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size,
NX_NULL,
NX_NULL);
@@ -540,13 +562,13 @@ USHORT signature_algorithm_id;
(NX_CRYPTO_METHOD*)hash_method,
NX_NULL,
0,
- tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random,
+ tls_key_material -> nx_secure_tls_client_random,
32,
NX_NULL,
NX_NULL,
0,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size,
NX_NULL,
NX_NULL);
@@ -560,13 +582,13 @@ USHORT signature_algorithm_id;
(NX_CRYPTO_METHOD*)hash_method,
NX_NULL,
0,
- tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random,
+ tls_key_material -> nx_secure_tls_server_random,
32,
NX_NULL,
NX_NULL,
0,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size,
NX_NULL,
NX_NULL);
@@ -585,8 +607,8 @@ USHORT signature_algorithm_id;
NX_NULL,
NX_NULL,
0,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size,
NX_NULL,
NX_NULL);
@@ -605,8 +627,8 @@ USHORT signature_algorithm_id;
NX_NULL,
&hash[16],
hash_method -> nx_crypto_ICV_size_in_bits >> 3,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
- tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch,
+ tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size,
NX_NULL,
NX_NULL);
@@ -617,7 +639,7 @@ USHORT signature_algorithm_id;
if (hash_method -> nx_crypto_cleanup)
{
- status = hash_method -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch);
+ status = hash_method -> nx_crypto_cleanup(tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch);
if(status != NX_CRYPTO_SUCCESS)
{
@@ -630,12 +652,12 @@ USHORT signature_algorithm_id;
#if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED)
#ifdef NX_SECURE_ENABLE_DTLS
- if (tls_session -> nx_secure_tls_protocol_version != NX_SECURE_TLS_VERSION_TLS_1_0 &&
- tls_session -> nx_secure_tls_protocol_version != NX_SECURE_TLS_VERSION_TLS_1_1 &&
- tls_session -> nx_secure_tls_protocol_version != NX_SECURE_DTLS_VERSION_1_0)
+ if (protocol_version != NX_SECURE_TLS_VERSION_TLS_1_0 &&
+ protocol_version != NX_SECURE_TLS_VERSION_TLS_1_1 &&
+ protocol_version != NX_SECURE_DTLS_VERSION_1_0)
#else
- if (tls_session -> nx_secure_tls_protocol_version != NX_SECURE_TLS_VERSION_TLS_1_0 &&
- tls_session -> nx_secure_tls_protocol_version != NX_SECURE_TLS_VERSION_TLS_1_1)
+ if (protocol_version != NX_SECURE_TLS_VERSION_TLS_1_0 &&
+ protocol_version != NX_SECURE_TLS_VERSION_TLS_1_1)
#endif /* NX_SECURE_ENABLE_DTLS */
#endif /* NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED */
{
@@ -647,7 +669,7 @@ USHORT signature_algorithm_id;
}
/* Sign the hash. */
- auth_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth;
+ auth_method = ciphersuite -> nx_secure_tls_public_auth;
if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA &&
(auth_method -> nx_crypto_algorithm == NX_CRYPTO_DIGITAL_SIGNATURE_RSA ||
auth_method -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_RSA))
@@ -662,13 +684,13 @@ USHORT signature_algorithm_id;
#if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED)
#ifdef NX_SECURE_ENABLE_DTLS
if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA &&
- (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0))
+ (protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
+ protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 ||
+ protocol_version == NX_SECURE_DTLS_VERSION_1_0))
#else
if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA &&
- (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1))
+ (protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
+ protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1))
#endif /* NX_SECURE_ENABLE_DTLS */
{
hash_length += hash_method -> nx_crypto_ICV_size_in_bits >> 3;
@@ -741,8 +763,8 @@ USHORT signature_algorithm_id;
(UCHAR *)certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_modulus,
(NX_CRYPTO_KEY_SIZE)(certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_modulus_length << 3),
&handler,
- tls_session -> nx_secure_public_auth_metadata_area,
- tls_session -> nx_secure_public_auth_metadata_size);
+ public_auth_metadata,
+ public_auth_metadata_size);
if (status != NX_CRYPTO_SUCCESS)
{
return(status);
@@ -761,8 +783,8 @@ USHORT signature_algorithm_id;
NX_NULL,
&public_key[length],
signature_length,
- tls_session -> nx_secure_public_auth_metadata_area,
- tls_session -> nx_secure_public_auth_metadata_size,
+ public_auth_metadata,
+ public_auth_metadata_size,
NX_NULL, NX_NULL);
if (status != NX_CRYPTO_SUCCESS)
{
@@ -774,7 +796,7 @@ USHORT signature_algorithm_id;
if (auth_method -> nx_crypto_cleanup)
{
- status = auth_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_auth_metadata_area);
+ status = auth_method -> nx_crypto_cleanup(public_auth_metadata);
if(status != NX_CRYPTO_SUCCESS)
{
@@ -789,7 +811,7 @@ USHORT signature_algorithm_id;
ec_pubkey = &certificate -> nx_secure_x509_public_key.ec_public_key;
/* Find out which named curve the local certificate is using. */
- status = _nx_secure_tls_find_curve_method(tls_session, (USHORT)(ec_privkey -> nx_secure_ec_named_curve), &curve_method_cert, NX_NULL);
+ status = _nx_secure_tls_find_curve_method(tls_ecc_curves, (USHORT)(ec_privkey -> nx_secure_ec_named_curve), &curve_method_cert, NX_NULL);
if(status != NX_SUCCESS)
{
return(status);
@@ -801,8 +823,8 @@ USHORT signature_algorithm_id;
(UCHAR *)ec_pubkey -> nx_secure_ec_public_key,
(NX_CRYPTO_KEY_SIZE)(ec_pubkey -> nx_secure_ec_public_key_length << 3),
&handler,
- tls_session -> nx_secure_public_auth_metadata_area,
- tls_session -> nx_secure_public_auth_metadata_size);
+ public_auth_metadata,
+ public_auth_metadata_size);
if (status != NX_CRYPTO_SUCCESS)
{
return(status);
@@ -817,8 +839,8 @@ USHORT signature_algorithm_id;
(NX_CRYPTO_METHOD*)auth_method, NX_NULL, 0,
(UCHAR *)curve_method_cert, sizeof(NX_CRYPTO_METHOD *), NX_NULL,
NX_NULL, 0,
- tls_session -> nx_secure_public_auth_metadata_area,
- tls_session -> nx_secure_public_auth_metadata_size,
+ public_auth_metadata,
+ public_auth_metadata_size,
NX_NULL, NX_NULL);
if (status != NX_CRYPTO_SUCCESS)
{
@@ -837,8 +859,8 @@ USHORT signature_algorithm_id;
hash_method -> nx_crypto_ICV_size_in_bits >> 3, NX_NULL,
(UCHAR *)&extended_output,
sizeof(extended_output),
- tls_session -> nx_secure_public_auth_metadata_area,
- tls_session -> nx_secure_public_auth_metadata_size,
+ public_auth_metadata,
+ public_auth_metadata_size,
NX_NULL, NX_NULL);
if (status != NX_CRYPTO_SUCCESS)
{
@@ -847,7 +869,7 @@ USHORT signature_algorithm_id;
if (auth_method -> nx_crypto_cleanup)
{
- status = auth_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_auth_metadata_area);
+ status = auth_method -> nx_crypto_cleanup(public_auth_metadata);
if(status != NX_CRYPTO_SUCCESS)
{
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_find_curve_method.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_find_curve_method.c
index 6618adeb..b1173266 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_find_curve_method.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_find_curve_method.c
@@ -31,7 +31,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_secure_tls_find_curve_method PORTABLE C */
-/* 6.1.6 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -87,21 +87,24 @@
/* 04-02-2021 Timothy Stapko Modified comment(s), added */
/* ECC curve table in X509, */
/* resulting in version 6.1.6 */
+/* 10-31-2022 Yanwu Cai Modified comment(s), */
+/* updated parameters list, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
-UINT _nx_secure_tls_find_curve_method(NX_SECURE_TLS_SESSION *tls_session,
- USHORT named_curve, const NX_CRYPTO_METHOD **curve_method, UINT *curve_priority)
+UINT _nx_secure_tls_find_curve_method(NX_SECURE_TLS_ECC *tls_ecc, USHORT named_curve,
+ const NX_CRYPTO_METHOD **curve_method, UINT *curve_priority)
{
USHORT i;
*curve_method = NX_NULL;
/* Find out the curve method for the named curve. */
- for (i = 0; i < tls_session -> nx_secure_tls_ecc.nx_secure_tls_ecc_supported_groups_count; i++)
+ for (i = 0; i < tls_ecc -> nx_secure_tls_ecc_supported_groups_count; i++)
{
- if (named_curve == tls_session -> nx_secure_tls_ecc.nx_secure_tls_ecc_supported_groups[i])
+ if (named_curve == tls_ecc -> nx_secure_tls_ecc_supported_groups[i])
{
- *curve_method = tls_session -> nx_secure_tls_ecc.nx_secure_tls_ecc_curves[i];
+ *curve_method = tls_ecc -> nx_secure_tls_ecc_curves[i];
/* The index in the supported list is the curve priority: lower value == higher priority. */
if(curve_priority != NX_NULL)
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_finished_hash_generate.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_finished_hash_generate.c
index 99ec5388..4961b2cb 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_finished_hash_generate.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_finished_hash_generate.c
@@ -136,7 +136,7 @@ UINT hash_size = 0;
#endif /* NX_SECURE_ENABLE_DTLS */
{
/* Copy over the handshake hash state into scratch space to do the intermediate calculation. */
- NX_SECURE_HASH_METADATA_CLONE(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch,
+ NX_SECURE_HASH_METADATA_CLONE(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, /* lgtm[cpp/banned-api-usage-required-any] */
tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha256_metadata,
tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha256_metadata_size); /* Use case of memcpy is verified. */
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_keys.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_keys.c
index 6666c335..df5939b6 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_keys.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_keys.c
@@ -27,15 +27,13 @@
#include "nx_secure_dtls.h"
#endif /* NX_SECURE_ENABLE_DTLS */
-/* This local static buffer needs to be large enough to hold both the server random and the client random. */
-static UCHAR _nx_secure_tls_gen_keys_random[NX_SECURE_TLS_RANDOM_SIZE + NX_SECURE_TLS_RANDOM_SIZE];
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nx_secure_tls_generate_keys PORTABLE C */
-/* 6.1 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -57,8 +55,8 @@ static UCHAR _nx_secure_tls_gen_keys_random[NX_SECURE_TLS_RANDOM_SIZE + NX_SECUR
/* */
/* CALLS */
/* */
-/* [nx_crypto_init] Initialize crypto */
-/* [nx_crypto_operation] Crypto operation */
+/* [nx_secure_generate_master_secret] Generate master secrets */
+/* [nx_secure_generate_session_keys] Generate session keys */
/* */
/* CALLED BY */
/* */
@@ -75,6 +73,9 @@ static UCHAR _nx_secure_tls_gen_keys_random[NX_SECURE_TLS_RANDOM_SIZE + NX_SECUR
/* 09-30-2020 Timothy Stapko Modified comment(s), */
/* verified memcpy use cases, */
/* resulting in version 6.1 */
+/* 10-31-2022 Yanwu Cai Modified comment(s), added */
+/* custom secret generation, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_secure_tls_generate_keys(NX_SECURE_TLS_SESSION *tls_session)
@@ -82,27 +83,14 @@ UINT _nx_secure_tls_generate_keys(NX_SECURE_TLS_SESSION *tls_session)
UCHAR *pre_master_sec;
UINT pre_master_sec_size;
UCHAR *master_sec;
-UCHAR *key_block; /* Maximum ciphersuite key size - AES_256_CBC_SHA, 2x32 byte keys + 2x20 byte MAC secrets + 2x16 IVs. */
-UINT key_block_size;
-UINT key_size;
-UINT hash_size;
-UINT iv_size;
UINT status;
-const NX_CRYPTO_METHOD *session_cipher_method = NX_NULL;
const NX_CRYPTO_METHOD *session_prf_method = NX_NULL;
const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite;
-VOID *handler = NX_NULL;
/* Generate the session keys using the parameters obtained in the handshake.
By this point all the information needed to generate the TLS session key
material should have been gathered and stored in the TLS socket structure. */
- key_block_size = 0;
-
- /* Working pointer into our new key material block since we are generating new keys. */
- key_block = tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data;
-
-
/* Generate the Master Secret from the Pre-Master Secret.
From the RFC (TLS 1.1, TLS 1.2):
@@ -122,241 +110,60 @@ VOID *handler = NX_NULL;
return(NX_SECURE_TLS_UNKNOWN_CIPHERSUITE);
}
- /* Get our session cipher method so we can get key sizes. */
- session_cipher_method = ciphersuite -> nx_secure_tls_session_cipher;
-
- /* The generation of key material is different between RSA and DH. */
- if (ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_RSA
-#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE
- || ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDHE
- || ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDH
-#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */
-#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES
- || ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_PSK
-#endif
-#ifdef NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE
- || ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECJPAKE
-#endif
- )
- {
- pre_master_sec = tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret;
- pre_master_sec_size = tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size;
- master_sec = tls_session -> nx_secure_tls_key_material.nx_secure_tls_master_secret;
+ pre_master_sec = tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret;
+ pre_master_sec_size = tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size;
+ master_sec = tls_session -> nx_secure_tls_key_material.nx_secure_tls_master_secret;
- /* Concatenate random values to feed into PRF. */
- NX_SECURE_MEMCPY(_nx_secure_tls_gen_keys_random, tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random,
- NX_SECURE_TLS_RANDOM_SIZE); /* Use case of memcpy is verified. */
- NX_SECURE_MEMCPY(&_nx_secure_tls_gen_keys_random[NX_SECURE_TLS_RANDOM_SIZE],
- tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random, NX_SECURE_TLS_RANDOM_SIZE); /* Use case of memcpy is verified. */
- /* Generate the master secret using the pre-master secret, the defined TLS label, and the concatenated
- random values. */
#if (NX_SECURE_TLS_TLS_1_2_ENABLED)
#ifdef NX_SECURE_ENABLE_DTLS
- if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_2 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_2)
+ if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_2 ||
+ tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_2)
#else
- if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_2)
+ if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_2)
#endif /* NX_SECURE_ENABLE_DTLS */
- {
- /* For TLS 1.2, the PRF is defined by the ciphersuite. However, if we are using an older ciphersuite,
- * default to the TLS 1.2 default PRF, which uses SHA-256-HMAC. */
- session_prf_method = ciphersuite -> nx_secure_tls_prf;
- }
+ {
+ /* For TLS 1.2, the PRF is defined by the ciphersuite. However, if we are using an older ciphersuite,
+ * default to the TLS 1.2 default PRF, which uses SHA-256-HMAC. */
+ session_prf_method = ciphersuite -> nx_secure_tls_prf;
+ }
#endif
#if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED)
#ifdef NX_SECURE_ENABLE_DTLS
- if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0)
+ if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
+ tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 ||
+ tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0)
#else
- if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
- tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1)
+ if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 ||
+ tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1)
#endif /* NX_SECURE_ENABLE_DTLS */
- {
- /* TLS 1.0 and TLS 1.1 use the same PRF. */
- session_prf_method = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_prf_1_method;
- }
-#endif
- /* If we don't have a PRF method, the version is wrong! */
- if (session_prf_method == NX_NULL)
- {
-#ifdef NX_SECURE_KEY_CLEAR
- NX_SECURE_MEMSET(_nx_secure_tls_gen_keys_random, 0, sizeof(_nx_secure_tls_gen_keys_random));
-#endif /* NX_SECURE_KEY_CLEAR */
-
- return(NX_SECURE_TLS_PROTOCOL_VERSION_CHANGED);
- }
-
- /* Use the PRF to generate the master secret. */
- if (session_prf_method -> nx_crypto_init != NX_NULL)
- {
- status = session_prf_method -> nx_crypto_init((NX_CRYPTO_METHOD*)session_prf_method,
- pre_master_sec, (NX_CRYPTO_KEY_SIZE)pre_master_sec_size,
- &handler,
- tls_session -> nx_secure_tls_prf_metadata_area,
- tls_session -> nx_secure_tls_prf_metadata_size);
-
- if(status != NX_CRYPTO_SUCCESS)
- {
-#ifdef NX_SECURE_KEY_CLEAR
- NX_SECURE_MEMSET(_nx_secure_tls_gen_keys_random, 0, sizeof(_nx_secure_tls_gen_keys_random));
-#endif /* NX_SECURE_KEY_CLEAR */
-
- return(status);
- }
- }
-
- if (session_prf_method -> nx_crypto_operation != NX_NULL)
- {
- status = session_prf_method -> nx_crypto_operation(NX_CRYPTO_PRF,
- handler,
- (NX_CRYPTO_METHOD*)session_prf_method,
- (UCHAR *)"master secret",
- 13,
- _nx_secure_tls_gen_keys_random,
- 64,
- NX_NULL,
- master_sec,
- 48,
- tls_session -> nx_secure_tls_prf_metadata_area,
- tls_session -> nx_secure_tls_prf_metadata_size,
- NX_NULL,
- NX_NULL);
-
-#ifdef NX_SECURE_KEY_CLEAR
- NX_SECURE_MEMSET(_nx_secure_tls_gen_keys_random, 0, sizeof(_nx_secure_tls_gen_keys_random));
-#endif /* NX_SECURE_KEY_CLEAR */
-
- if(status != NX_CRYPTO_SUCCESS)
- {
- /* Secrets cleared above. */
- return(status);
- }
- }
-
- if (session_prf_method -> nx_crypto_cleanup)
- {
- status = session_prf_method -> nx_crypto_cleanup(tls_session -> nx_secure_tls_prf_metadata_area);
-
- if(status != NX_CRYPTO_SUCCESS)
- {
- /* All secrets cleared above. */
- return(status);
- }
- }
- }
- else
{
- /* The chosen cipher is not supported. Likely an internal error since negotiation has already finished. */
- return(NX_SECURE_TLS_UNSUPPORTED_CIPHER);
+ /* TLS 1.0 and TLS 1.1 use the same PRF. */
+ session_prf_method = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_prf_1_method;
}
+#endif
- /* Clear out the Pre-Master Secret (we don't need it anymore and keeping it in memory is dangerous). */
-#ifdef NX_SECURE_KEY_CLEAR
- NX_SECURE_MEMSET(pre_master_sec, 0x0, sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret));
-#endif /* NX_SECURE_KEY_CLEAR */
-
- /* Lookup ciphersuite data for key size. We need 2 keys for each session. */
- key_size = session_cipher_method -> nx_crypto_key_size_in_bits >> 3;
-
- /* Lookup ciphersuite data for hash size - used for the MAC secret. */
- hash_size = ciphersuite -> nx_secure_tls_hash_size;
-
- /* Lookup initialization vector size. */
- iv_size = session_cipher_method -> nx_crypto_IV_size_in_bits >> 3;
-
- /* Now calculate block size. Need client and server for each key, hash, and iv. Note that
- key size and iv size may be zero depending on the ciphersuite, particularly when using
- the NULL ciphers. */
- key_block_size = 2 * (key_size + hash_size + iv_size);
-
- /* Now generate keys from the master secret we obtained above. */
- /* From the RFC (TLS 1.1):
- To generate the key material, compute
-
- key_block = PRF(SecurityParameters.master_secret,
- "key expansion",
- SecurityParameters.server_random +
- SecurityParameters.client_random);
-
- until enough output has been generated. Then the key_block is
- partitioned as follows:
-
- client_write_MAC_secret[SecurityParameters.hash_size]
- server_write_MAC_secret[SecurityParameters.hash_size]
- client_write_key[SecurityParameters.key_material_length]
- server_write_key[SecurityParameters.key_material_length]
- */
-
- /* The order of the randoms is reversed from that used for the master secret
- when generating the key block. */
- NX_SECURE_MEMCPY(_nx_secure_tls_gen_keys_random, tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random,
- NX_SECURE_TLS_RANDOM_SIZE); /* Use case of memcpy is verified. */
- NX_SECURE_MEMCPY(&_nx_secure_tls_gen_keys_random[NX_SECURE_TLS_RANDOM_SIZE],
- tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, NX_SECURE_TLS_RANDOM_SIZE); /* Use case of memcpy is verified. */
+ status = tls_session -> nx_secure_generate_master_secret(ciphersuite, tls_session -> nx_secure_tls_protocol_version, session_prf_method,
+ &tls_session -> nx_secure_tls_key_material, pre_master_sec, pre_master_sec_size,
+ master_sec, tls_session -> nx_secure_tls_prf_metadata_area,
+ tls_session -> nx_secure_tls_prf_metadata_size);
- /* Key expansion uses the PRF to generate a block of key material from the master secret (generated
- above) and the client and server random values transmitted during the initial hello negotiation. */
- if (session_prf_method -> nx_crypto_init != NX_NULL)
+ if (status != NX_SECURE_TLS_SUCCESS)
{
- status = session_prf_method -> nx_crypto_init((NX_CRYPTO_METHOD*)session_prf_method,
- master_sec, 48,
- &handler,
- tls_session -> nx_secure_tls_prf_metadata_area,
- tls_session -> nx_secure_tls_prf_metadata_size);
-
- if(status != NX_CRYPTO_SUCCESS)
- {
-#ifdef NX_SECURE_KEY_CLEAR
- NX_SECURE_MEMSET(_nx_secure_tls_gen_keys_random, 0, sizeof(_nx_secure_tls_gen_keys_random));
-#endif /* NX_SECURE_KEY_CLEAR */
- return(status);
- }
+ return(status);
}
- if (session_prf_method -> nx_crypto_operation != NX_NULL)
- {
- status = session_prf_method -> nx_crypto_operation(NX_CRYPTO_PRF,
- handler,
- (NX_CRYPTO_METHOD*)session_prf_method,
- (UCHAR *)"key expansion",
- 13,
- _nx_secure_tls_gen_keys_random,
- 64,
- NX_NULL,
- key_block,
- key_block_size,
- tls_session -> nx_secure_tls_prf_metadata_area,
- tls_session -> nx_secure_tls_prf_metadata_size,
- NX_NULL,
- NX_NULL);
-
+ /* Clear out the Pre-Master Secret (we don't need it anymore and keeping it in memory is dangerous). */
#ifdef NX_SECURE_KEY_CLEAR
- /* We now have a key block, clear our temporary secrets buffer. */
- NX_SECURE_MEMSET(_nx_secure_tls_gen_keys_random, 0, sizeof(_nx_secure_tls_gen_keys_random));
+ NX_SECURE_MEMSET(pre_master_sec, 0x0, sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret));
#endif /* NX_SECURE_KEY_CLEAR */
- if(status != NX_CRYPTO_SUCCESS)
- {
- /* Secrets cleared above. */
- return(status);
- }
- }
-
- if (session_prf_method -> nx_crypto_cleanup)
- {
- status = session_prf_method -> nx_crypto_cleanup(tls_session -> nx_secure_tls_prf_metadata_area);
-
- if(status != NX_CRYPTO_SUCCESS)
- {
- /* Secrets cleared above. */
- return(status);
- }
- }
- return(NX_SECURE_TLS_SUCCESS);
+ status = tls_session -> nx_secure_generate_session_keys(ciphersuite, tls_session -> nx_secure_tls_protocol_version, session_prf_method,
+ &tls_session -> nx_secure_tls_key_material, master_sec, tls_session -> nx_secure_tls_prf_metadata_area,
+ tls_session -> nx_secure_tls_prf_metadata_size);
+ return(status);
}
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_premaster_secret.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_premaster_secret.c
index 54b2dbf4..f1140aca 100644
--- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_premaster_secret.c
+++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_premaster_secret.c
@@ -29,7 +29,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_secure_tls_generate_premaster_secret PORTABLE C */
-/* 6.1.11 */
+/* 6.2.0 */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -51,10 +51,8 @@
/* */
/* CALLS */
/* */
-/* _nx_secure_tls_psk_find Find PSK from store */
-/* _nx_secure_tls_find_curve_method Find named curve used */
-/* [nx_crypto_init] Initialize crypto */
-/* [nx_crypto_operation] Crypto operation */
+/* _nx_secure_tls_protocol_version_get Get current TLS version to use*/
+/* [nx_secure_generate_premaster_secret] Generate pre-master secret */
/* */
/* CALLED BY */
/* */
@@ -75,27 +73,15 @@
/* 04-25-2022 Yuxin Zhou Modified comment(s), removed */
/* internal unreachable logic, */
/* resulting in version 6.1.11 */
+/* 10-31-2022 Yanwu Cai Modified comment(s), added */
+/* custom secret generation, */
+/* resulting in version 6.2.0 */
/* */
/**************************************************************************/
UINT _nx_secure_tls_generate_premaster_secret(NX_SECURE_TLS_SESSION *tls_session, UINT id)
{
-UINT *buffer_ptr;
-UINT i;
-UINT status = NX_SECURE_TLS_SUCCESS;
-USHORT protocol_version;
-#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES
-UCHAR *psk_data;
-UINT psk_length;
-UINT index;
-#endif
-#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE
-NX_SECURE_X509_CERT *server_certificate;
-const NX_CRYPTO_METHOD *curve_method_cert;
-const NX_CRYPTO_METHOD *ecdh_method;
-NX_SECURE_EC_PUBLIC_KEY *ec_pubkey;
-VOID *handler = NX_NULL;
-NX_CRYPTO_EXTENDED_OUTPUT extended_output;
-#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */
+UINT status;
+USHORT protocol_version;
if (tls_session -> nx_secure_tls_session_ciphersuite == NX_NULL)
{
@@ -104,211 +90,23 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output;
return(NX_SECURE_TLS_UNKNOWN_CIPHERSUITE);
}
-#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE
- if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDHE)
- {
-
- return(NX_SECURE_TLS_SUCCESS);
- }
- else if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDH)
- {
- /* Get reference to remote server certificate so we can find out the named curve. */
- status = _nx_secure_x509_remote_endpoint_certificate_get(&tls_session -> nx_secure_tls_credentials.nx_secure_tls_certificate_store,
- &server_certificate);
- if (status)
- {
- /* No certificate found, error! */
- return(NX_SECURE_TLS_CERTIFICATE_NOT_FOUND);
- }
-
- ec_pubkey = &server_certificate -> nx_secure_x509_public_key.ec_public_key;
-
- /* Find out which named curve the remote certificate is using. */
- status = _nx_secure_tls_find_curve_method(tls_session, (USHORT)(ec_pubkey -> nx_secure_ec_named_curve), &curve_method_cert, NX_NULL);
-
- if(status != NX_SUCCESS)
- {
- return(status);
- }
-
- ecdh_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher;
- if (ecdh_method -> nx_crypto_operation == NX_NULL)
- {
- return(NX_SECURE_TLS_MISSING_CRYPTO_ROUTINE);
- }
-
- if (ecdh_method -> nx_crypto_init != NX_NULL)
- {
- status = ecdh_method -> nx_crypto_init((NX_CRYPTO_METHOD*)ecdh_method,
- NX_NULL,
- 0,
- &handler,
- tls_session -> nx_secure_public_cipher_metadata_area,
- tls_session -> nx_secure_public_cipher_metadata_size);
- if(status != NX_CRYPTO_SUCCESS)
- {
- return(status);
- }
- }
-
- status = ecdh_method -> nx_crypto_operation(NX_CRYPTO_EC_CURVE_SET, handler,
- (NX_CRYPTO_METHOD*)ecdh_method, NX_NULL, 0,
- (UCHAR *)curve_method_cert, sizeof(NX_CRYPTO_METHOD *), NX_NULL,
- NX_NULL, 0,
- tls_session -> nx_secure_public_cipher_metadata_area,
- tls_session -> nx_secure_public_cipher_metadata_size,
- NX_NULL, NX_NULL);
- if (status != NX_CRYPTO_SUCCESS)
- {
- return(status);
- }
-
- /* Store public key in the nx_secure_tls_new_key_material_data. */
- extended_output.nx_crypto_extended_output_data = &tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[1];
- extended_output.nx_crypto_extended_output_length_in_byte = sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data) - 1;
- extended_output.nx_crypto_extended_output_actual_size = 0;
- status = ecdh_method -> nx_crypto_operation(NX_CRYPTO_DH_SETUP, handler,
- (NX_CRYPTO_METHOD*)ecdh_method, NX_NULL, 0,
- NX_NULL, 0, NX_NULL,
- (UCHAR *)&extended_output,
- sizeof(extended_output),
- tls_session -> nx_secure_public_cipher_metadata_area,
- tls_session -> nx_secure_public_cipher_metadata_size,
- NX_NULL, NX_NULL);
- if (status != NX_CRYPTO_SUCCESS)
- {
- return(status);
- }
-
- tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[0] = (UCHAR)extended_output.nx_crypto_extended_output_actual_size;
-
- extended_output.nx_crypto_extended_output_data = tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret;
- extended_output.nx_crypto_extended_output_length_in_byte = sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret);
- extended_output.nx_crypto_extended_output_actual_size = 0;
- status = ecdh_method -> nx_crypto_operation(NX_CRYPTO_DH_CALCULATE, handler,
- (NX_CRYPTO_METHOD*)ecdh_method, NX_NULL, 0,
- (UCHAR *)ec_pubkey -> nx_secure_ec_public_key,
- ec_pubkey -> nx_secure_ec_public_key_length, NX_NULL,
- (UCHAR *)&extended_output,
- sizeof(extended_output),
- tls_session -> nx_secure_public_cipher_metadata_area,
- tls_session -> nx_secure_public_cipher_metadata_size,
- NX_NULL, NX_NULL);
- if (status != NX_CRYPTO_SUCCESS)
- {
- return(status);
- }
-
- tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size = extended_output.nx_crypto_extended_output_actual_size;
-
- if (ecdh_method -> nx_crypto_cleanup)
- {
- status = ecdh_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_cipher_metadata_area);
- if(status != NX_CRYPTO_SUCCESS)
- {
- return(status);
- }
- }
-
- return(NX_SECURE_TLS_SUCCESS);
- }
-#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */
-
-#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES
- /* Check for PSK ciphersuites. */
- if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_PSK)
- {
- /* Now, using the identity as a key, find the PSK in our PSK store. */
- if (tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_SERVER)
- {
- /* Server just uses its PSK. */
- psk_data = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[0].nx_secure_tls_psk_data;
- psk_length = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[0].nx_secure_tls_psk_data_size;
- }
- else
- {
- /* Client has to search for the PSK based on the identity hint. */
- status = _nx_secure_tls_psk_find(tls_session, &psk_data, &psk_length, tls_session -> nx_secure_tls_credentials.nx_secure_tls_remote_psk_id,
- tls_session -> nx_secure_tls_credentials.nx_secure_tls_remote_psk_id_size, NX_NULL);
-
- if (status != NX_SUCCESS)
- {
- return(status);
- }
- }
-
- /* From RFC 4279:
- The premaster secret is formed as follows: if the PSK is N octets
- long, concatenate a uint16 with the value N, N zero octets, a second
- uint16 with the value N, and the PSK itself.
- | 2 |