From 1ebdcfca4f15962ec3d9c3ff8ef7aeb2eaa81d67 Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 4 Nov 2024 01:04:54 +0000 Subject: [PATCH] edhoc: Encode C_x as CBOR This used the wrong encoding function, which made no difference before when only short C_x were supported. --- lib/src/edhoc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/edhoc.rs b/lib/src/edhoc.rs index e877fc6e..5c6ab238 100644 --- a/lib/src/edhoc.rs +++ b/lib/src/edhoc.rs @@ -511,7 +511,7 @@ fn encode_message_1( output.content[2 + raw_suites_len] = P256_ELEM_LEN as u8; // length of the byte string output.content[3 + raw_suites_len..3 + raw_suites_len + P256_ELEM_LEN] .copy_from_slice(&g_x[..]); - let c_i = c_i.as_slice(); + let c_i = c_i.as_cbor(); output.len = 3 + raw_suites_len + P256_ELEM_LEN + c_i.len(); output.content[3 + raw_suites_len + P256_ELEM_LEN..][..c_i.len()].copy_from_slice(c_i); @@ -858,7 +858,7 @@ fn encode_plaintext_2( ead_2: &Option, ) -> Result { let mut plaintext_2: BufferPlaintext2 = BufferPlaintext2::new(); - let c_r = c_r.as_slice(); + let c_r = c_r.as_cbor(); plaintext_2 .extend_from_slice(c_r)