From 83da142649693785832adf8b0a5f0b2cbd402d1b Mon Sep 17 00:00:00 2001 From: Geovane Fedrecheski <geonnave@gmail.com> Date: Fri, 30 Aug 2024 17:07:59 +0200 Subject: [PATCH] examples: fix after new credential api --- examples/lakers-c-native/main.c | 2 +- examples/lakers-nrf52840/src/bin/initiator.rs | 15 +++++++++------ examples/lakers-nrf52840/src/bin/responder.rs | 11 ++++++++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/lakers-c-native/main.c b/examples/lakers-c-native/main.c index 35b87549..565192cd 100644 --- a/examples/lakers-c-native/main.c +++ b/examples/lakers-c-native/main.c @@ -153,7 +153,7 @@ int main(void) memcpy(message_2.content, coap_response_payload, coap_response_payload_len); EADItemC ead_2 = {0}; uint8_t c_r; - CredentialC id_cred_r = {0}; + IdCred id_cred_r = {0}; #ifdef LAKERS_EAD_AUTHZ // res = initiator_parse_message_2(&initiator, &message_2, &cred_r, &c_r, &id_cred_r, &ead_2); res = initiator_parse_message_2(&initiator, &message_2, &c_r, &id_cred_r, &ead_2); diff --git a/examples/lakers-nrf52840/src/bin/initiator.rs b/examples/lakers-nrf52840/src/bin/initiator.rs index 6efc6156..1171b6c0 100644 --- a/examples/lakers-nrf52840/src/bin/initiator.rs +++ b/examples/lakers-nrf52840/src/bin/initiator.rs @@ -66,10 +66,15 @@ async fn main(spawner: Spawner) { mbedtls_memory_buffer_alloc_init(buffer.as_mut_ptr(), buffer.len()); } - let cred_i = CredentialRPK::new(common::CRED_I.try_into().unwrap()).unwrap(); - let cred_r = CredentialRPK::new(common::CRED_R.try_into().unwrap()).unwrap(); + let cred_i = Credential::parse_ccs(common::CRED_I.try_into().unwrap()).unwrap(); + let cred_r = Credential::parse_ccs(common::CRED_R.try_into().unwrap()).unwrap(); - let mut initiator = EdhocInitiator::new(lakers_crypto::default_crypto()); + let mut initiator = EdhocInitiator::new( + lakers_crypto::default_crypto(), + EDHOCMethod::StatStat, + EDHOCSuite::CipherSuite2, + ); + initiator.set_identity(common::I.try_into().unwrap(), cred_i); // Send Message 1 over raw BLE and convert the response to byte let c_i = generate_connection_identifier_cbor(&mut lakers_crypto::default_crypto()); @@ -85,9 +90,7 @@ async fn main(spawner: Spawner) { pckt_2.pdu[1..pckt_2.len].try_into().expect("wrong length"); let (initiator, c_r, id_cred_r, ead_2) = initiator.parse_message_2(&message_2).unwrap(); let valid_cred_r = credential_check_or_fetch(Some(cred_r), id_cred_r).unwrap(); - let initiator = initiator - .verify_message_2(common::I, cred_i, valid_cred_r) - .unwrap(); + let initiator = initiator.verify_message_2(valid_cred_r).unwrap(); let (mut initiator, message_3, i_prk_out) = initiator .prepare_message_3(CredentialTransfer::ByReference, &None) diff --git a/examples/lakers-nrf52840/src/bin/responder.rs b/examples/lakers-nrf52840/src/bin/responder.rs index de8b8518..2c086bae 100644 --- a/examples/lakers-nrf52840/src/bin/responder.rs +++ b/examples/lakers-nrf52840/src/bin/responder.rs @@ -69,8 +69,13 @@ async fn main(spawner: Spawner) { info!("Received message_1"); - let cred_r = CredentialRPK::new(common::CRED_R.try_into().unwrap()).unwrap(); - let responder = EdhocResponder::new(lakers_crypto::default_crypto(), &common::R, cred_r); + let cred_r = Credential::parse_ccs(common::CRED_R.try_into().unwrap()).unwrap(); + let responder = EdhocResponder::new( + lakers_crypto::default_crypto(), + EDHOCMethod::StatStat, + common::R.try_into().unwrap(), + cred_r, + ); let message_1: EdhocMessageBuffer = pckt.pdu[1..pckt.len].try_into().expect("wrong length"); // get rid of the TRUE byte @@ -114,7 +119,7 @@ async fn main(spawner: Spawner) { }; let cred_i = - CredentialRPK::new(common::CRED_I.try_into().unwrap()).unwrap(); + Credential::parse_ccs(common::CRED_I.try_into().unwrap()).unwrap(); let valid_cred_i = credential_check_or_fetch(Some(cred_i), id_cred_i).unwrap();