Skip to content

Commit

Permalink
update samples
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanHri committed May 19, 2024
1 parent d15ff47 commit 77e698a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
6 changes: 3 additions & 3 deletions makefile_config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
24 changes: 16 additions & 8 deletions samples/linux_edhoc_oscore/initiator_client/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(&params, &c_client));

TRY(oscore_context_init(&p, &c_client));

uint8_t buf_oscore[256];
uint8_t coap_rx_buf[256];
Expand Down Expand Up @@ -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");
Expand Down
16 changes: 12 additions & 4 deletions samples/linux_edhoc_oscore/responder_server/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(&params, &c_server));
Expand Down

0 comments on commit 77e698a

Please sign in to comment.