#[repr(C)]pub struct IdCred {
pub bytes: BufferIdCred,
}Expand description
A value of ID_CRED_x: a credential identifier.
Possible values include key IDs, credentials by value and others.
let short_kid = IdCred::from_encoded_value(&hex!("17")).unwrap(); // 23
assert_eq!(short_kid.as_full_value(), &hex!("a1044117")); // {4: h'17'}
let long_kid = IdCred::from_encoded_value(&hex!("43616263")).unwrap(); // 'abc'
assert_eq!(long_kid.as_full_value(), &hex!("a10443616263")); // {4: 'abc'}Fields§
§bytes: BufferIdCredThe value is always stored in the ID_CRED_x form as a serialized one-element dictionary; while this technically wastes two bytes, it has the convenient property of having the full value available as a slice.
Implementations§
Source§impl IdCred
impl IdCred
pub fn new() -> Self
pub fn from_full_value(value: &[u8]) -> Result<Self, EDHOCError>
Sourcepub fn from_encoded_value(value: &[u8]) -> Result<Self, EDHOCError>
pub fn from_encoded_value(value: &[u8]) -> Result<Self, EDHOCError>
Instantiate an IdCred from an encoded value.
Sourcepub fn as_full_value(&self) -> &[u8]
pub fn as_full_value(&self) -> &[u8]
View the full value of the ID_CRED_x: the CBOR encoding of a 1-element CBOR map
This is the value that is used when ID_CRED_x has no impact on message size, see RFC 9528 Section 3.5.3.2.
Sourcepub fn as_encoded_value(&self) -> &[u8]
pub fn as_encoded_value(&self) -> &[u8]
View the value as encoded in the ID_CRED_x position of plaintext_2 and plaintext_3.
Note that this is NOT doing CBOR encoding, it is rather performing (when applicable) the compact encoding of ID_CRED fields. This style of encoding is used when ID_CRED_x has an impact on message size.