Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/common/cbor_values/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use core::fmt::{Debug, Display, Formatter};
use core::ops::Deref;

use coset::{CoseEncrypt0, CoseKey};
use coset::{CoseEncrypt0, CoseKey, OscoreInputMaterial};
use strum_macros::IntoStaticStr;

#[cfg(not(feature = "std"))]
Expand Down Expand Up @@ -91,6 +91,10 @@ pub enum ProofOfPossessionKey {
///
/// For details, see [section 3.4 of RFC 8747](https://datatracker.ietf.org/doc/html/rfc8747#section-3.4).
KeyId(KeyId),

/// OSCORE input material that is used in the ACE OSCORE profile (RFC 9203), in which
/// parameters for OSCORE communication are established.
OscoreInputMaterial(OscoreInputMaterial),
}

impl ProofOfPossessionKey {
Expand All @@ -117,6 +121,7 @@ impl ProofOfPossessionKey {
&k.protected.header.key_id
}
}
ProofOfPossessionKey::OscoreInputMaterial(_) => todo!(),
}
}
}
Expand Down Expand Up @@ -212,6 +217,7 @@ mod conversion {
let x: i128 = 3;
vec![(x, Some(Box::new(Value::Bytes(kid.clone()))))]
}
Self::OscoreInputMaterial(_) => todo!(),
}
}

Expand Down Expand Up @@ -240,6 +246,13 @@ mod conversion {
))
}),
(3, Value::Bytes(x)) => Ok(ProofOfPossessionKey::KeyId(x)),
(4, m @ Value::Map(_)) => OscoreInputMaterial::from_cbor_value(m)
.map(ProofOfPossessionKey::OscoreInputMaterial)
.map_err(|x| {
TryFromCborMapError::from_message(format!(
"couldn't create OscoreInputMaterial from CBOR value: {x}"
))
}),
(x, _) => Err(TryFromCborMapError::unknown_field(u8::try_from(x)?)),
}
} else {
Expand Down