#[repr(C)]pub struct Credential {
pub bytes: BufferCred,
pub key: CredentialKey,
pub kid: Option<BufferKid>,
pub cred_type: CredentialType,
}Expand description
A credential for use in EDHOC
For now supports CCS credentials only. Experimental support for CCS_PSK credentials is also available.
Fields§
§bytes: BufferCredOriginal bytes of the credential, CBOR-encoded
If the credential is a CCS, it contains an encoded CBOR map containnig a COSE_Key in a cnf claim, see RFC 9528 Section 3.5.2.
key: CredentialKey§kid: Option<BufferKid>§cred_type: CredentialTypeImplementations§
Source§impl Credential
impl Credential
Sourcepub fn new_ccs(bytes: BufferCred, public_key: BytesKeyEC2) -> Self
pub fn new_ccs(bytes: BufferCred, public_key: BytesKeyEC2) -> Self
Creates a new CCS credential with the given bytes and public key
Sourcepub fn new_ccs_symmetric(
bytes: BufferCred,
symmetric_key: BytesKeyAES128,
) -> Self
pub fn new_ccs_symmetric( bytes: BufferCred, symmetric_key: BytesKeyAES128, ) -> Self
Creates a new CCS credential with the given bytes and a pre-shared key
NOTE: For now this is only useful for the experimental PSK method.
pub fn with_kid(self, kid: BufferKid) -> Self
pub fn public_key(&self) -> Option<BytesKeyEC2>
Sourcepub fn parse_ccs(value: &[u8]) -> Result<Self, EDHOCError>
pub fn parse_ccs(value: &[u8]) -> Result<Self, EDHOCError>
Parse a CCS style credential.
If the given value matches the shape lakers expects of a CCS, i.e. credentials from RFC9529, its public key and key ID are extracted into a full credential.
Sourcepub fn parse_ccs_symmetric(value: &[u8]) -> Result<Self, EDHOCError>
pub fn parse_ccs_symmetric(value: &[u8]) -> Result<Self, EDHOCError>
Parse a CCS style credential, but the key is a symmetric key.
NOTE: For now this is only useful for the experimental PSK method.
Sourcepub fn by_value(&self) -> Result<IdCred, EDHOCError>
pub fn by_value(&self) -> Result<IdCred, EDHOCError>
Returns a COSE_Header map with a single entry representing a credential by value.
For example, if the credential is a CCS: { /kccs/ 14: bytes }
Sourcepub fn by_kid(&self) -> Result<IdCred, EDHOCError>
pub fn by_kid(&self) -> Result<IdCred, EDHOCError>
Returns a COSE_Header map with a single entry representing a credential by reference.
For example, if the reference is a kid: { /kid/ 4: kid }
TODO: accept a parameter to specify the type of reference, e.g. kid, x5t, etc.
Trait Implementations§
Source§impl Clone for Credential
impl Clone for Credential
Source§fn clone(&self) -> Credential
fn clone(&self) -> Credential
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more