From 77e698a753927d2353cd2935feba82a1fdacd933 Mon Sep 17 00:00:00 2001 From: Stefan Hristozov Date: Sun, 19 May 2024 18:17:44 +0200 Subject: [PATCH] update samples --- makefile_config.mk | 6 ++--- .../initiator_client/src/main.cpp | 24 ++++++++++++------- .../responder_server/src/main.cpp | 16 +++++++++---- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/makefile_config.mk b/makefile_config.mk index dbc19ee2..27212b5a 100644 --- a/makefile_config.mk +++ b/makefile_config.mk @@ -25,7 +25,7 @@ OPT = -O0 ################################################################################ # Print helpful debug messages ################################################################################ -DEBUG_PRINT += -DDEBUG_PRINT +#DEBUG_PRINT += -DDEBUG_PRINT ################################################################################ # Use Address Sanitizer, e.g. with native_posix @@ -46,7 +46,7 @@ UNIT_TEST += -DUNIT_TEST CBOR_ENGINE += -DZCBOR # Uncomment to enable Non-volatile memory (NVM) support for storing security context between device reboots -OSCORE_NVM_SUPPORT += -DOSCORE_NVM_SUPPORT +#OSCORE_NVM_SUPPORT += -DOSCORE_NVM_SUPPORT ################################################################################ # RAM optimization @@ -60,7 +60,7 @@ OSCORE_NVM_SUPPORT += -DOSCORE_NVM_SUPPORT ################################################################################ # In deployments where no protected application message is sent from the # Responder to the Initiator, message_4 MUST be used. -FEATURES += -DMESSAGE_4 +# FEATURES += -DMESSAGE_4 # If EAD is not used set its buffer size to 0 FEATURES += -DEAD_SIZE=0 diff --git a/samples/linux_edhoc_oscore/initiator_client/src/main.cpp b/samples/linux_edhoc_oscore/initiator_client/src/main.cpp index 2688bbe4..8cb337bd 100644 --- a/samples/linux_edhoc_oscore/initiator_client/src/main.cpp +++ b/samples/linux_edhoc_oscore/initiator_client/src/main.cpp @@ -241,23 +241,32 @@ int main() int32_t n; CoapPDU *protected_pdu = new CoapPDU(); - /*OSCORE contex initialization*/ - oscore_init_params params = { + /*OSCORE context initialization*/ + struct oscore_init_params p = { + /*master secret*/ oscore_master_secret.len, oscore_master_secret.ptr, - T1__SENDER_ID_LEN, - (uint8_t *)T1__SENDER_ID, - T1__RECIPIENT_ID_LEN, - (uint8_t *)T1__RECIPIENT_ID, + /*sender_id*/ + test_vectors[vec_num_i].c_r_len, + (uint8_t *)test_vectors[vec_num_i].c_r, + /*recipient_id*/ + test_vectors[vec_num_i].c_i_len, + (uint8_t *)test_vectors[vec_num_i].c_i, + /*id_context*/ T1__ID_CONTEXT_LEN, (uint8_t *)T1__ID_CONTEXT, + /*master_salt*/ oscore_master_salt.len, oscore_master_salt.ptr, + /*aead_alg*/ OSCORE_AES_CCM_16_64_128, + /*hkdf*/ OSCORE_SHA_256, + /*fresh_master_secret_salt*/ true, }; - TRY(oscore_context_init(¶ms, &c_client)); + + TRY(oscore_context_init(&p, &c_client)); uint8_t buf_oscore[256]; uint8_t coap_rx_buf[256]; @@ -285,7 +294,6 @@ int main() second_request = false; } - if (protected_pdu->validate()) { printf("\n=================================================\n"); printf("CoAP message to be protected with OSOCRE\n"); diff --git a/samples/linux_edhoc_oscore/responder_server/src/main.cpp b/samples/linux_edhoc_oscore/responder_server/src/main.cpp index e027c092..9f1c9c5c 100644 --- a/samples/linux_edhoc_oscore/responder_server/src/main.cpp +++ b/samples/linux_edhoc_oscore/responder_server/src/main.cpp @@ -313,18 +313,26 @@ int main() /*OSCORE contex initialization*/ oscore_init_params params = { + /*master secret*/ oscore_master_secret.len, oscore_master_secret.ptr, - T1__RECIPIENT_ID_LEN, - (uint8_t *)T1__RECIPIENT_ID, - T1__SENDER_ID_LEN, - (uint8_t *)T1__SENDER_ID, + /*sender_id*/ + test_vectors[vec_num_i].c_i_len, + (uint8_t *)test_vectors[vec_num_i].c_i, + /*recipient_id*/ + test_vectors[vec_num_i].c_r_len, + (uint8_t *)test_vectors[vec_num_i].c_r, + /*id_context*/ T1__ID_CONTEXT_LEN, (uint8_t *)T1__ID_CONTEXT, + /*master_salt*/ oscore_master_salt.len, oscore_master_salt.ptr, + /*aead_alg*/ OSCORE_AES_CCM_16_64_128, + /*hkdf*/ OSCORE_SHA_256, + /*fresh_master_secret_salt*/ true, }; TRY(oscore_context_init(¶ms, &c_server));