summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/BSD/nxd_bsd.c9
-rw-r--r--addons/azure_iot/nx_azure_iot.c1
-rw-r--r--addons/azure_iot/nx_azure_iot.h2
-rw-r--r--addons/azure_iot/nx_azure_iot_adu_agent.c26
-rw-r--r--addons/azure_iot/nx_azure_iot_adu_agent.h8
-rw-r--r--addons/azure_iot/nx_azure_iot_adu_root_key.c2
-rw-r--r--addons/azure_iot/nx_azure_iot_hub_client.c2
-rw-r--r--addons/azure_iot/nx_azure_iot_hub_client.h2
-rw-r--r--addons/azure_iot/nx_azure_iot_hub_client_properties.c2
-rw-r--r--addons/azure_iot/nx_azure_iot_hub_client_properties.h2
-rw-r--r--addons/azure_iot/nx_azure_iot_json_reader.c2
-rw-r--r--addons/azure_iot/nx_azure_iot_json_reader.h2
-rw-r--r--addons/azure_iot/nx_azure_iot_json_writer.c2
-rw-r--r--addons/azure_iot/nx_azure_iot_json_writer.h2
-rw-r--r--addons/azure_iot/nx_azure_iot_provisioning_client.c2
-rw-r--r--addons/azure_iot/nx_azure_iot_provisioning_client.h2
-rw-r--r--addons/azure_iot/samples/sample_azure_iot_embedded_sdk_pnp.c2
-rw-r--r--addons/sntp/nxd_sntp_client.c21
-rw-r--r--addons/telnet/nxd_telnet_client.c8
-rw-r--r--crypto_libraries/src/nx_crypto_rsa.c35
-rw-r--r--nx_secure/inc/nx_secure_x509.h9
-rw-r--r--nx_secure/src/nx_secure_tls_1_3_client_handshake.c18
-rw-r--r--nx_secure/src/nx_secure_tls_1_3_finished_hash_generate.c10
-rw-r--r--nx_secure/src/nx_secure_tls_process_finished.c9
-rw-r--r--nx_secure/src/nx_secure_tls_process_record.c8
-rw-r--r--nx_secure/src/nx_secure_tls_process_remote_certificate.c13
-rw-r--r--nx_secure/src/nx_secure_tls_send_clienthello_extensions.c7
-rw-r--r--nx_secure/src/nx_secure_tls_send_serverhello_extensions.c9
-rw-r--r--nx_secure/src/nx_secure_tls_session_receive_records.c11
29 files changed, 140 insertions, 88 deletions
diff --git a/addons/BSD/nxd_bsd.c b/addons/BSD/nxd_bsd.c
index 84fe6e61..41f45003 100644
--- a/addons/BSD/nxd_bsd.c
+++ b/addons/BSD/nxd_bsd.c
@@ -5266,7 +5266,7 @@ NX_BSD_SOCKET *bsd_socket_ptr;
/* FUNCTION RELEASE */
/* */
/* ioctl PORTABLE C */
-/* 6.1 */
+/* 6.x */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -5308,6 +5308,9 @@ NX_BSD_SOCKET *bsd_socket_ptr;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* xx-xx-xxxx Wenhui Xie Modified comment(s), corrected*/
+/* the result of FIONREAD, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
INT ioctl(INT sockID, INT command, INT *result)
@@ -5386,6 +5389,10 @@ UINT status;
NX_BSD_ERROR(NX_BSD_MUTEX_ERROR, __LINE__);
return(NX_SOC_ERROR);
}
+ else
+ {
+ *result += (INT)(bsd_socket_ptr -> nx_bsd_socket_received_byte_count);
+ }
}
else if (udp_socket_ptr)
{
diff --git a/addons/azure_iot/nx_azure_iot.c b/addons/azure_iot/nx_azure_iot.c
index 06bfcf68..6eb889a8 100644
--- a/addons/azure_iot/nx_azure_iot.c
+++ b/addons/azure_iot/nx_azure_iot.c
@@ -9,7 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
#include <stdio.h>
#include <stdarg.h>
diff --git a/addons/azure_iot/nx_azure_iot.h b/addons/azure_iot/nx_azure_iot.h
index beee5e74..71791617 100644
--- a/addons/azure_iot/nx_azure_iot.h
+++ b/addons/azure_iot/nx_azure_iot.h
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
/**
* @file nx_azure_iot.h
*
diff --git a/addons/azure_iot/nx_azure_iot_adu_agent.c b/addons/azure_iot/nx_azure_iot_adu_agent.c
index c4da49a5..efdebcfa 100644
--- a/addons/azure_iot/nx_azure_iot_adu_agent.c
+++ b/addons/azure_iot/nx_azure_iot_adu_agent.c
@@ -9,10 +9,16 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
#include "nx_azure_iot_adu_agent.h"
+/* ADU Version e.g: AzureRTOS;agent/x.x.x */
+#define NX_AZURE_IOT_ADU_AGENT_STR(C) #C
+#define NX_AZURE_IOT_ADU_AGENT_TO_STR(x) NX_AZURE_IOT_ADU_AGENT_STR(x)
+#define NX_AZURE_IOT_ADU_AGENT_VERSION "AzureRTOS;agent/" \
+ NX_AZURE_IOT_ADU_AGENT_TO_STR(NETXDUO_MAJOR_VERSION) "." \
+ NX_AZURE_IOT_ADU_AGENT_TO_STR(NETXDUO_MINOR_VERSION) "." \
+ NX_AZURE_IOT_ADU_AGENT_TO_STR(NETXDUO_PATCH_VERSION)
+
/* Update buffer pointer and buffer size. */
#define NX_AZURE_IOT_ADU_AGENT_PTR_UPDATE(a, b, c, d) { \
(a) = (c); \
@@ -501,6 +507,9 @@ NX_AZURE_IOT_ADU_AGENT *adu_agent_ptr = (NX_AZURE_IOT_ADU_AGENT *)args;
/* Reset the state. */
adu_agent_ptr -> nx_azure_iot_adu_agent_state = NX_AZURE_IOT_ADU_AGENT_STATE_IDLE;
+ /* Report idle state to server. */
+ nx_azure_iot_adu_agent_reported_properties_state_send(adu_agent_ptr);
+
LogInfo(LogLiteralArgs("Cancel Command received"));
return(NX_AZURE_IOT_SUCCESS);
}
@@ -3006,10 +3015,15 @@ UINT response_status;
sizeof(NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_MODEL) - 1,
device_properties -> model, device_properties -> model_length)) ||
(nx_azure_iot_json_writer_append_property_with_string_value(&json_writer,
- (const UCHAR *)NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_INTERFACE_ID,
- sizeof(NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_INTERFACE_ID) - 1,
- (const UCHAR *)NX_AZURE_IOT_ADU_AGENT_INTERFACE_ID,
- sizeof(NX_AZURE_IOT_ADU_AGENT_INTERFACE_ID) - 1)) ||
+ (const UCHAR *)NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_CONTRACT_MODEL_ID,
+ sizeof(NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_CONTRACT_MODEL_ID) - 1,
+ (const UCHAR *)NX_AZURE_IOT_ADU_AGENT_CONTRACT_MODEL_ID,
+ sizeof(NX_AZURE_IOT_ADU_AGENT_CONTRACT_MODEL_ID) - 1)) ||
+ (nx_azure_iot_json_writer_append_property_with_string_value(&json_writer,
+ (const UCHAR *)NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_ADU_VERSION,
+ sizeof(NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_ADU_VERSION) - 1,
+ (const UCHAR *)NX_AZURE_IOT_ADU_AGENT_VERSION,
+ sizeof(NX_AZURE_IOT_ADU_AGENT_VERSION) - 1)) ||
(nx_azure_iot_json_writer_append_end_object(&json_writer)))
{
nx_packet_release(packet_ptr);
diff --git a/addons/azure_iot/nx_azure_iot_adu_agent.h b/addons/azure_iot/nx_azure_iot_adu_agent.h
index 6cb1ff4a..00e0f4f8 100644
--- a/addons/azure_iot/nx_azure_iot_adu_agent.h
+++ b/addons/azure_iot/nx_azure_iot_adu_agent.h
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
/**
* @file nx_azure_iot_adu_agent.h
*
@@ -44,8 +42,8 @@ extern "C" {
/* Define the ADU agent component name. */
#define NX_AZURE_IOT_ADU_AGENT_COMPONENT_NAME "deviceUpdate"
-/* Define the ADU agent interface ID. */
-#define NX_AZURE_IOT_ADU_AGENT_INTERFACE_ID "dtmi:azure:iot:deviceUpdate;1"
+/* Define the ADU agent contract model ID. */
+#define NX_AZURE_IOT_ADU_AGENT_CONTRACT_MODEL_ID "dtmi:azure:iot:deviceUpdateContractModel;2"
/* Define the compatibility value. */
#define NX_AZURE_IOT_ADU_AGENT_PROPERTY_VALUE_COMPATIBILITY "manufacturer,model"
@@ -56,7 +54,7 @@ extern "C" {
#define NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_DEVICEPROPERTIES "deviceProperties"
#define NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_MANUFACTURER "manufacturer"
#define NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_MODEL "model"
-#define NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_INTERFACE_ID "interfaceId"
+#define NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_CONTRACT_MODEL_ID "contractModelId"
#define NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_ADU_VERSION "aduVer"
#define NX_AZURE_IOT_ADU_AGENT_PROPERTY_NAME_DO_VERSION "doVer"
diff --git a/addons/azure_iot/nx_azure_iot_adu_root_key.c b/addons/azure_iot/nx_azure_iot_adu_root_key.c
index c9dc54e2..098d36fa 100644
--- a/addons/azure_iot/nx_azure_iot_adu_root_key.c
+++ b/addons/azure_iot/nx_azure_iot_adu_root_key.c
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
#include "nx_azure_iot_adu_agent.h"
/* Update manifest is meant for ADU devices to know what files are needed to be downloaded and installed.
diff --git a/addons/azure_iot/nx_azure_iot_hub_client.c b/addons/azure_iot/nx_azure_iot_hub_client.c
index 8d8f3917..2847b454 100644
--- a/addons/azure_iot/nx_azure_iot_hub_client.c
+++ b/addons/azure_iot/nx_azure_iot_hub_client.c
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
#include "nx_azure_iot_hub_client.h"
#include "azure/core/az_version.h"
diff --git a/addons/azure_iot/nx_azure_iot_hub_client.h b/addons/azure_iot/nx_azure_iot_hub_client.h
index 4ff16d59..c4c20db9 100644
--- a/addons/azure_iot/nx_azure_iot_hub_client.h
+++ b/addons/azure_iot/nx_azure_iot_hub_client.h
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
/**
* @file nx_azure_iot_hub_client.h
*
diff --git a/addons/azure_iot/nx_azure_iot_hub_client_properties.c b/addons/azure_iot/nx_azure_iot_hub_client_properties.c
index cd1740aa..a7d30734 100644
--- a/addons/azure_iot/nx_azure_iot_hub_client_properties.c
+++ b/addons/azure_iot/nx_azure_iot_hub_client_properties.c
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
#include "nx_azure_iot_hub_client_properties.h"
extern UINT nx_azure_iot_hub_client_adjust_payload(NX_PACKET *packet_ptr);
diff --git a/addons/azure_iot/nx_azure_iot_hub_client_properties.h b/addons/azure_iot/nx_azure_iot_hub_client_properties.h
index 91d0ffd9..15be9396 100644
--- a/addons/azure_iot/nx_azure_iot_hub_client_properties.h
+++ b/addons/azure_iot/nx_azure_iot_hub_client_properties.h
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
/**
* @file nx_azure_iot_hub_client.h
*
diff --git a/addons/azure_iot/nx_azure_iot_json_reader.c b/addons/azure_iot/nx_azure_iot_json_reader.c
index 031bb97f..45544534 100644
--- a/addons/azure_iot/nx_azure_iot_json_reader.c
+++ b/addons/azure_iot/nx_azure_iot_json_reader.c
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
#include "nx_azure_iot_json_reader.h"
#include "nx_azure_iot.h"
diff --git a/addons/azure_iot/nx_azure_iot_json_reader.h b/addons/azure_iot/nx_azure_iot_json_reader.h
index 62157de9..2ffdb89b 100644
--- a/addons/azure_iot/nx_azure_iot_json_reader.h
+++ b/addons/azure_iot/nx_azure_iot_json_reader.h
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
/**
* @file nx_azure_iot_json_reader.h
*
diff --git a/addons/azure_iot/nx_azure_iot_json_writer.c b/addons/azure_iot/nx_azure_iot_json_writer.c
index 4c18b339..cf39becf 100644
--- a/addons/azure_iot/nx_azure_iot_json_writer.c
+++ b/addons/azure_iot/nx_azure_iot_json_writer.c
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
#include "nx_azure_iot_json_writer.h"
#include "nx_azure_iot.h"
diff --git a/addons/azure_iot/nx_azure_iot_json_writer.h b/addons/azure_iot/nx_azure_iot_json_writer.h
index 6a6a3622..641c9aed 100644
--- a/addons/azure_iot/nx_azure_iot_json_writer.h
+++ b/addons/azure_iot/nx_azure_iot_json_writer.h
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
/**
* @file nx_azure_iot_json_writer.h
*
diff --git a/addons/azure_iot/nx_azure_iot_provisioning_client.c b/addons/azure_iot/nx_azure_iot_provisioning_client.c
index cc12b028..a0c96528 100644
--- a/addons/azure_iot/nx_azure_iot_provisioning_client.c
+++ b/addons/azure_iot/nx_azure_iot_provisioning_client.c
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
#include "nx_azure_iot_provisioning_client.h"
#include "azure/core/az_span.h"
diff --git a/addons/azure_iot/nx_azure_iot_provisioning_client.h b/addons/azure_iot/nx_azure_iot_provisioning_client.h
index 01d88dbc..95a2089c 100644
--- a/addons/azure_iot/nx_azure_iot_provisioning_client.h
+++ b/addons/azure_iot/nx_azure_iot_provisioning_client.h
@@ -9,8 +9,6 @@
/* */
/**************************************************************************/
-/* Version: 6.1 */
-
/**
* @file nx_azure_iot_provisioning_client.h
*
diff --git a/addons/azure_iot/samples/sample_azure_iot_embedded_sdk_pnp.c b/addons/azure_iot/samples/sample_azure_iot_embedded_sdk_pnp.c
index c5db826e..d7e82d0d 100644
--- a/addons/azure_iot/samples/sample_azure_iot_embedded_sdk_pnp.c
+++ b/addons/azure_iot/samples/sample_azure_iot_embedded_sdk_pnp.c
@@ -43,7 +43,7 @@
#define SAMPLE_COMMAND_SUCCESS_STATUS (200)
#define SAMPLE_COMMAND_ERROR_STATUS (500)
-#define SAMPLE_PNP_MODEL_ID "dtmi:com:example:Thermostat;3"
+#define SAMPLE_PNP_MODEL_ID "dtmi:com:example:Thermostat;4"
#define SAMPLE_PNP_DPS_PAYLOAD "{\"modelId\":\"" SAMPLE_PNP_MODEL_ID "\"}"
/* Generally, IoTHub Client and DPS Client do not run at the same time, user can use union as below to
diff --git a/addons/sntp/nxd_sntp_client.c b/addons/sntp/nxd_sntp_client.c
index c275ea54..160597ab 100644
--- a/addons/sntp/nxd_sntp_client.c
+++ b/addons/sntp/nxd_sntp_client.c
@@ -85,7 +85,7 @@ static ULONG process_timerticks = 0;
/* FUNCTION RELEASE */
/* */
/* _nxe_sntp_client_create PORTABLE C */
-/* 6.1 */
+/* 6.x */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -126,6 +126,9 @@ static ULONG process_timerticks = 0;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* xx-xx-xxxx Wenhui Xie Modified comment(s), */
+/* checked the client ID, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
UINT _nxe_sntp_client_create(NX_SNTP_CLIENT *client_ptr, NX_IP *ip_ptr, UINT iface_index, NX_PACKET_POOL *packet_pool_ptr,
@@ -145,6 +148,14 @@ UINT status;
return(NX_PTR_ERROR);
}
+ /* Check for the client ID. */
+ if ((client_ptr == NX_NULL) || (client_ptr -> nx_sntp_client_id == NXD_SNTP_ID))
+ {
+
+ /* Return error status. */
+ return(NX_PTR_ERROR);
+ }
+
/* Check for invalid network interface input. */
if (iface_index >= NX_MAX_PHYSICAL_INTERFACES)
{
@@ -449,7 +460,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_sntp_client_delete PORTABLE C */
-/* 6.1 */
+/* 6.x */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -489,11 +500,17 @@ UINT status;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
+/* xx-xx-xxxx Wenhui Xie Modified comment(s), */
+/* cleared the client ID, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
UINT _nx_sntp_client_delete(NX_SNTP_CLIENT *client_ptr)
{
+ /* Clear the client ID. */
+ client_ptr -> nx_sntp_client_id = 0;
+
/* Suspend the SNTP Client thread. */
tx_thread_suspend(&client_ptr -> nx_sntp_client_thread);
diff --git a/addons/telnet/nxd_telnet_client.c b/addons/telnet/nxd_telnet_client.c
index c88bf30d..51c9b71c 100644
--- a/addons/telnet/nxd_telnet_client.c
+++ b/addons/telnet/nxd_telnet_client.c
@@ -567,7 +567,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_telnet_client_delete PORTABLE C */
-/* 6.1 */
+/* 6.x */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@@ -600,6 +600,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 */
+/* xx-xx-xxxx Wenhui Xie Modified comment(s), */
+/* cleared the client ID, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
UINT _nx_telnet_client_delete(NX_TELNET_CLIENT *client_ptr)
@@ -613,6 +616,9 @@ UINT _nx_telnet_client_delete(NX_TELNET_CLIENT *client_ptr)
return(NX_TELNET_NOT_DISCONNECTED);
}
+ /* Clear the client ID. */
+ client_ptr -> nx_telnet_client_id = 0;
+
/* Delete the socket. */
nx_tcp_socket_delete(&(client_ptr -> nx_telnet_client_socket));
diff --git a/crypto_libraries/src/nx_crypto_rsa.c b/crypto_libraries/src/nx_crypto_rsa.c
index f15c350d..4b35fd0d 100644
--- a/crypto_libraries/src/nx_crypto_rsa.c
+++ b/crypto_libraries/src/nx_crypto_rsa.c
@@ -85,6 +85,9 @@
/* 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 Yanwu Cai Modified comment(s), aligned */
+/* buffer size of huge number, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
NX_CRYPTO_KEEP UINT _nx_crypto_rsa_operation(const UCHAR *exponent, UINT exponent_length, const UCHAR *modulus, UINT modulus_length,
@@ -92,7 +95,7 @@ NX_CRYPTO_KEEP UINT _nx_crypto_rsa_operation(const UCHAR *exponent, UINT expone
const UCHAR *input, UINT input_length, UCHAR *output,
USHORT *scratch_buf_ptr, UINT scratch_buf_length)
{
-UCHAR *scratch;
+HN_UBASE *scratch;
UINT mod_length;
NX_CRYPTO_HUGE_NUMBER modulus_hn, exponent_hn, input_hn, output_hn, p_hn, q_hn;
@@ -100,27 +103,19 @@ NX_CRYPTO_HUGE_NUMBER modulus_hn, exponent_hn, input_hn, output_hn, p_hn, q_hn;
/* The RSA operation is reversible so both encryption and decryption can be done with the same operation. */
/* Local pointer for pointer arithmetic. */
- scratch = (UCHAR *)scratch_buf_ptr;
+ scratch = (HN_UBASE *)scratch_buf_ptr;
/* Set up each of the buffers - point into the scratch buffer at increments of the DH buffer size. */
- modulus_hn.nx_crypto_huge_number_data = (HN_UBASE *)scratch;
- scratch += modulus_length;
- modulus_hn.nx_crypto_huge_buffer_size = modulus_length;
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&modulus_hn, scratch, modulus_length);
/* Input buffer(and scratch). */
- input_hn.nx_crypto_huge_number_data = (HN_UBASE *)scratch;
- scratch += modulus_length;
- input_hn.nx_crypto_huge_buffer_size = modulus_length;
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&input_hn, scratch, modulus_length);
/* Exponent buffer (and scratch). */
- exponent_hn.nx_crypto_huge_number_data = (HN_UBASE *)scratch;
- scratch += modulus_length;
- exponent_hn.nx_crypto_huge_buffer_size = modulus_length;
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&exponent_hn, scratch, modulus_length);
/* Output buffer (and scratch). */
- output_hn.nx_crypto_huge_number_data = (HN_UBASE *)scratch;
- scratch += modulus_length * 2;
- output_hn.nx_crypto_huge_buffer_size = modulus_length * 2;
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&output_hn, scratch, modulus_length << 1);
/* Copy the exponent from the caller's buffer. */
_nx_crypto_huge_number_setup(&exponent_hn, exponent, exponent_length);
@@ -134,13 +129,9 @@ NX_CRYPTO_HUGE_NUMBER modulus_hn, exponent_hn, input_hn, output_hn, p_hn, q_hn;
if (p && q)
{
- p_hn.nx_crypto_huge_number_data = (HN_UBASE *)scratch;
- scratch += (modulus_length >> 1);
- p_hn.nx_crypto_huge_buffer_size = (modulus_length >> 1);
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&p_hn, scratch, modulus_length >> 1);
- q_hn.nx_crypto_huge_number_data = (HN_UBASE *)scratch;
- scratch += (modulus_length >> 1);
- q_hn.nx_crypto_huge_buffer_size = (modulus_length >> 1);
+ NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&q_hn, scratch, modulus_length >> 1);
/* Copy the prime p and q from the caller's buffer. */
_nx_crypto_huge_number_setup(&p_hn, p, p_length);
@@ -151,7 +142,7 @@ NX_CRYPTO_HUGE_NUMBER modulus_hn, exponent_hn, input_hn, output_hn, p_hn, q_hn;
where the "**" denotes exponentiation. */
_nx_crypto_huge_number_crt_power_modulus(&input_hn, &exponent_hn, &p_hn, &q_hn,
&modulus_hn, &output_hn,
- (HN_UBASE *)scratch);
+ scratch);
}
else
{
@@ -160,7 +151,7 @@ NX_CRYPTO_HUGE_NUMBER modulus_hn, exponent_hn, input_hn, output_hn, p_hn, q_hn;
The actual calculation is "shared_secret = (public_key**private_key) % modulus"
where the "**" denotes exponentiation. */
_nx_crypto_huge_number_mont_power_modulus(&input_hn, &exponent_hn, &modulus_hn,
- &output_hn, (HN_UBASE *)scratch);
+ &output_hn, scratch);
}
/* Copy the shared secret into the return buffer. */
diff --git a/nx_secure/inc/nx_secure_x509.h b/nx_secure/inc/nx_secure_x509.h
index a0189ed8..80f93baf 100644
--- a/nx_secure/inc/nx_secure_x509.h
+++ b/nx_secure/inc/nx_secure_x509.h
@@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* nx_secure_x509.h PORTABLE C */
-/* 6.1.12 */
+/* 6.x */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -59,6 +59,9 @@
/* checked expiration for all */
/* the certs in the chain, */
/* resulting in version 6.1.12 */
+/* xx-xx-xxxx Yanwu Cai Modified comment(s), */
+/* included TLS port header, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
@@ -76,6 +79,10 @@ extern "C" {
#include "nx_crypto.h"
+#ifndef NX_CRYPTO_STANDALONE_ENABLE
+#include "nx_secure_port.h"
+#endif
+
/* Enable ECC by default. */
#ifndef NX_SECURE_DISABLE_ECC_CIPHERSUITE
#ifndef NX_SECURE_ENABLE_ECC_CIPHERSUITE
diff --git a/nx_secure/src/nx_secure_tls_1_3_client_handshake.c b/nx_secure/src/nx_secure_tls_1_3_client_handshake.c
index 9e39bd63..afae8c98 100644
--- a/nx_secure/src/nx_secure_tls_1_3_client_handshake.c
+++ b/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.12 */
+/* 6.x */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -120,6 +120,9 @@
/* updated alert message for */
/* downgrade protection, */
/* resulting in version 6.1.12 */
+/* xx-xx-xxxx Tiejun Zhou Modified comment(s), and */
+/* corrected metadata cleanup, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
@@ -354,13 +357,6 @@ const UCHAR *server_random;
/* Update the transcript hash with the Finished. */
_nx_secure_tls_handshake_hash_update(tls_session, packet_start, message_length + header_bytes);
-
- /* For client, cleanup hash handler after received the finished message from server. */
- method_ptr = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_sha256_method;
- if (method_ptr -> nx_crypto_cleanup != NX_NULL)
- {
- status = method_ptr -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha256_metadata);
- }
break;
case NX_SECURE_TLS_CERTIFICATE_VERIFY:
/* Handle server-sent certificate verify. */
@@ -654,6 +650,12 @@ const UCHAR *server_random;
break;
}
+ /* For client, cleanup hash handler after sent the finished message to server. */
+ method_ptr = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_sha256_method;
+ if (method_ptr -> nx_crypto_cleanup != NX_NULL)
+ {
+ status = method_ptr -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha256_metadata);
+ }
break;
/* Cases not handled in TLS 1.3 (for reference):
diff --git a/nx_secure/src/nx_secure_tls_1_3_finished_hash_generate.c b/nx_secure/src/nx_secure_tls_1_3_finished_hash_generate.c
index 6815814a..2131dbaf 100644
--- a/nx_secure/src/nx_secure_tls_1_3_finished_hash_generate.c
+++ b/nx_secure/src/nx_secure_tls_1_3_finished_hash_generate.c
@@ -31,7 +31,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_secure_tls_1_3_finished_hash_generate PORTABLE C */
-/* 6.1 */
+/* 6.x */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -72,6 +72,9 @@
/* 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 */
+/* corrected hash cleanup, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
#if (NX_SECURE_TLS_TLS_1_3_ENABLED)
@@ -252,11 +255,6 @@ NX_SECURE_TLS_KEY_SECRETS *secrets;
return(NX_SECURE_TLS_MISSING_CRYPTO_ROUTINE);
}
-
-#ifdef NX_SECURE_KEY_CLEAR
- NX_SECURE_MEMSET(finished_hash, 0, *hash_size);
-#endif /* NX_SECURE_KEY_CLEAR */
-
return(NX_SUCCESS);
}
#endif
diff --git a/nx_secure/src/nx_secure_tls_process_finished.c b/nx_secure/src/nx_secure_tls_process_finished.c
index 346f1dc6..e349c141 100644
--- a/nx_secure/src/nx_secure_tls_process_finished.c
+++ b/nx_secure/src/nx_secure_tls_process_finished.c
@@ -77,6 +77,7 @@ static UCHAR generated_hash[NX_SECURE_TLS_MAX_HASH_SIZE];
/* xx-xx-xxxx Yanwu Cai Modified comment(s), */
/* fixed compiler errors when */
/* x509 is disabled, */
+/* corrected hash cleanup, */
/* resulting in version 6.x */
/* */
/**************************************************************************/
@@ -111,9 +112,13 @@ UINT is_server;
else
{
- /* Compare to see if the Finished hash matches the recevied hash. */
+ /* Compare to see if the Finished hash matches the received hash. */
compare_result = (UINT)NX_SECURE_MEMCMP(generated_hash, packet_buffer, hash_size);
}
+
+#ifdef NX_SECURE_KEY_CLEAR
+ NX_SECURE_MEMSET(generated_hash, 0, sizeof(generated_hash));
+#endif /* NX_SECURE_KEY_CLEAR */
}
else
#endif
@@ -164,7 +169,7 @@ UINT is_server;
NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_remote_verify_data, generated_hash, NX_SECURE_TLS_FINISHED_HASH_SIZE); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */
#endif /* NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION */
- /* The finished verify data is always 12 bytes (*except for SSLv3) - compare to see if the Finished hash matches the recevied hash. */
+ /* The finished verify data is always 12 bytes (*except for SSLv3) - compare to see if the Finished hash matches the received hash. */
compare_result = (UINT)NX_SECURE_MEMCMP(generated_hash, packet_buffer, NX_SECURE_TLS_FINISHED_HASH_SIZE);
}
diff --git a/nx_secure/src/nx_secure_tls_process_record.c b/nx_secure/src/nx_secure_tls_process_record.c
index 60a440d2..c91b1a84 100644
--- a/nx_secure/src/nx_secure_tls_process_record.c
+++ b/nx_secure/src/nx_secure_tls_process_record.c
@@ -31,7 +31,7 @@ static VOID _nx_secure_tls_packet_trim(NX_PACKET *packet_ptr);
/* FUNCTION RELEASE */
/* */
/* _nx_secure_tls_process_record PORTABLE C */
-/* 6.1.12 */
+/* 6.x */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -102,6 +102,9 @@ static VOID _nx_secure_tls_packet_trim(NX_PACKET *packet_ptr);
/* improved buffer length */
/* verification, */
/* resulting in version 6.1.12 */
+/* xx-xx-xxxx Tiejun Zhou Modified comment(s), and */
+/* corrected data cleanup, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
UINT _nx_secure_tls_process_record(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET *packet_ptr,
@@ -588,7 +591,8 @@ NX_PACKET *decrypted_packet;
}
#ifdef NX_SECURE_KEY_CLEAR
- if (message_type != NX_SECURE_TLS_APPLICATION_DATA)
+ if ((message_type != NX_SECURE_TLS_APPLICATION_DATA) &&
+ (status != NX_CONTINUE))
{
NX_SECURE_MEMSET(packet_data, 0, message_length);
}
diff --git a/nx_secure/src/nx_secure_tls_process_remote_certificate.c b/nx_secure/src/nx_secure_tls_process_remote_certificate.c
index b9799a7a..dd1eb315 100644
--- a/nx_secure/src/nx_secure_tls_process_remote_certificate.c
+++ b/nx_secure/src/nx_secure_tls_process_remote_certificate.c
@@ -90,6 +90,8 @@
/* xx-xx-xxxx Yanwu Cai Modified comment(s), */
/* fixed compiler errors when */
/* x509 is disabled, */
+/* initialized metadata for */
+/* remote certificate, */
/* resulting in version 6.x */
/* */
/**************************************************************************/
@@ -382,6 +384,17 @@ ULONG cert_buf_size;
/* Copy the certificate data to the end of the certificate buffer or use an allocated certificate. */
certificate -> nx_secure_x509_certificate_raw_data_length = endpoint_length;
NX_SECURE_MEMCPY(certificate->nx_secure_x509_certificate_raw_data, endpoint_raw_ptr, endpoint_length); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */
+
+ /* Assign the TLS Session metadata areas to the certificate for later use. */
+ certificate -> nx_secure_x509_public_cipher_metadata_area = tls_session -> nx_secure_public_cipher_metadata_area;
+ certificate -> nx_secure_x509_public_cipher_metadata_size = tls_session -> nx_secure_public_cipher_metadata_size;
+
+ certificate -> nx_secure_x509_hash_metadata_area = tls_session -> nx_secure_hash_mac_metadata_area;
+ certificate -> nx_secure_x509_hash_metadata_size = tls_session -> nx_secure_hash_mac_metadata_size;
+
+ /* Assign the cipher table from the parent TLS session. */
+ certificate -> nx_secure_x509_cipher_table = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_x509_cipher_table;
+ certificate -> nx_secure_x509_cipher_table_size = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_x509_cipher_table_size;
/* Release the protection. */
tx_mutex_put(&_nx_secure_tls_protection);
diff --git a/nx_secure/src/nx_secure_tls_send_clienthello_extensions.c b/nx_secure/src/nx_secure_tls_send_clienthello_extensions.c
index f785aad8..7bb0d1f4 100644
--- a/nx_secure/src/nx_secure_tls_send_clienthello_extensions.c
+++ b/nx_secure/src/nx_secure_tls_send_clienthello_extensions.c
@@ -511,7 +511,7 @@ UCHAR sig_algo = 0;
/* */
/* _nx_secure_tls_send_clienthello_supported_versions_extension */
/* PORTABLE C */
-/* 6.1 */
+/* 6.x */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -549,6 +549,9 @@ UCHAR sig_algo = 0;
/* 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), */
+/* fixed compiler warnings, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
#if (NX_SECURE_TLS_TLS_1_3_ENABLED)
@@ -562,8 +565,10 @@ ULONG offset;
USHORT ext;
UINT data_length;
UINT id = NX_SECURE_TLS;
+#ifndef NX_SECURE_TLS_DISABLE_PROTOCOL_VERSION_DOWNGRADE
USHORT protocol_version;
INT i;
+#endif /* NX_SECURE_TLS_DISABLE_PROTOCOL_VERSION_DOWNGRADE */
/* Supported Versions Extension structure:
* | 2 | 2 | 1 | <list length> |
diff --git a/nx_secure/src/nx_secure_tls_send_serverhello_extensions.c b/nx_secure/src/nx_secure_tls_send_serverhello_extensions.c
index 0339c209..c98a84b8 100644
--- a/nx_secure/src/nx_secure_tls_send_serverhello_extensions.c
+++ b/nx_secure/src/nx_secure_tls_send_serverhello_extensions.c
@@ -56,7 +56,7 @@ static UINT _nx_secure_tls_send_serverhello_psk_extension(NX_SECURE_TLS_SESSION
/* FUNCTION RELEASE */
/* */
/* _nx_secure_tls_send_serverhello_extensions PORTABLE C */
-/* 6.1.11 */
+/* 6.x */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -99,6 +99,9 @@ static UINT _nx_secure_tls_send_serverhello_psk_extension(NX_SECURE_TLS_SESSION
/* 04-25-2022 Yuxin Zhou Modified comment(s), */
/* removed unused code, */
/* resulting in version 6.1.11 */
+/* xx-xx-xxxx Tiejun Zhou Modified comment(s), */
+/* fixed compiler warnings, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
UINT _nx_secure_tls_send_serverhello_extensions(NX_SECURE_TLS_SESSION *tls_session,
@@ -113,9 +116,9 @@ USHORT extension_length = 0;
USHORT total_extensions_length;
UINT status = NX_SUCCESS;
-#if defined(NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION) && (!NX_SECURE_TLS_TLS_1_3_ENABLED)
+#if defined(NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION) || (!NX_SECURE_TLS_TLS_1_3_ENABLED)
NX_PARAMETER_NOT_USED(tls_session);
-#endif /* defined(NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION) && (!NX_SECURE_TLS_TLS_1_3_ENABLED) */
+#endif /* defined(NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION) || (!NX_SECURE_TLS_TLS_1_3_ENABLED) */
if (available_size < (*packet_offset + 2u))
{
diff --git a/nx_secure/src/nx_secure_tls_session_receive_records.c b/nx_secure/src/nx_secure_tls_session_receive_records.c
index 6ce34535..944c8532 100644
--- a/nx_secure/src/nx_secure_tls_session_receive_records.c
+++ b/nx_secure/src/nx_secure_tls_session_receive_records.c
@@ -29,7 +29,7 @@
/* FUNCTION RELEASE */
/* */
/* _nx_secure_tls_session_receive_records PORTABLE C */
-/* 6.1.11 */
+/* 6.x */
/* AUTHOR */
/* */
/* Timothy Stapko, Microsoft Corporation */
@@ -80,6 +80,9 @@
/* 04-25-2022 Yuxin Zhou Modified comment(s), added */
/* conditional TLS 1.3 build, */
/* resulting in version 6.1.11 */
+/* xx-xx-xxxx Yanwu Cai Modified comment(s), fixed */
+/* packet leak in TLS 1.3, */
+/* resulting in version 6.x */
/* */
/**************************************************************************/
UINT _nx_secure_tls_session_receive_records(NX_SECURE_TLS_SESSION *tls_session,
@@ -228,7 +231,11 @@ UCHAR handshake_finished = NX_FALSE;
}
#endif /* NX_SECURE_TLS_CLIENT_DISABLED */
- if (handshake_finished)
+ if (handshake_finished
+#if (NX_SECURE_TLS_TLS_1_3_ENABLED)
+ && status != NX_SECURE_TLS_POST_HANDSHAKE_RECEIVED
+#endif /* (NX_SECURE_TLS_TLS_1_3_ENABLED) */
+ )
{
if (tls_session -> nx_secure_record_decrypted_packet == NX_NULL)
{