From d2382968e0a0ce0e0bd8082eb6021a0cd0f37f83 Mon Sep 17 00:00:00 2001 From: chrysn Date: Wed, 15 May 2024 13:42:52 +0200 Subject: [PATCH] coap: Fix occasional failure when both peers pick the same C_x This would be legal in EDHOC, but OSCORE derivations will fail. --- examples/coap/src/seccontext.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/coap/src/seccontext.rs b/examples/coap/src/seccontext.rs index a2fd704d7..19ec1903b 100644 --- a/examples/coap/src/seccontext.rs +++ b/examples/coap/src/seccontext.rs @@ -485,7 +485,10 @@ impl<'a, H: coap_handler::Handler, L: Write> coap_handler::Handler let c_r = COwn::not_in_iter( self.pool .iter() - .filter_map(|entry| entry.corresponding_cown()), + .filter_map(|entry| entry.corresponding_cown()) + // C_R does not only need to be unique, it also must not be identical + // to C_I + .chain(COwn::from_kid(c_i.as_slice()).as_slice().into_iter().cloned()) ); writeln!(self.log, "Entries in pool:");