Enum dcaf::common::cbor_values::ProofOfPossessionKey
source · pub enum ProofOfPossessionKey {
PlainCoseKey(CoseKey),
EncryptedCoseKey(CoseEncrypt0),
KeyId(ByteString),
}
Expand description
A proof-of-possession key as specified by RFC 8747, section 3.1.
Can either be a COSE key, an encrypted COSE key, or simply a key ID.
As described in RFC 9201,
PoP keys are used for the req_cnf
parameter in AccessTokenRequest
,
as well as for the cnf
and rs_cnf
parameters in AccessTokenResponse
.
Example
We showcase creation of an AccessTokenRequest
in which we set req_cnf
to a PoP key
with an ID of 0xDCAF which the access token shall be bound to:
let key = ProofOfPossessionKey::KeyId(vec![0xDC, 0xAF]);
let request: AccessTokenRequest = AccessTokenRequest::builder().client_id("test_client").req_cnf(key).build()?;
assert_eq!(request.req_cnf.unwrap().key_id().to_vec(), vec![0xDC, 0xAF]);
Variants§
PlainCoseKey(CoseKey)
An unencrypted CoseKey
used to represent an asymmetric public key or
(if the CWT it’s contained in is encrypted) a symmetric key.
For details, see section 3.2 of RFC 8747.
EncryptedCoseKey(CoseEncrypt0)
An encrypted CoseKey
used to represent a symmetric key.
For details, see section 3.3 of RFC 8747.
KeyId(ByteString)
Key ID of the actual proof-of-possession key.
Note that as described in section 6 of RFC 8747, certain caveats apply when choosing to represent a proof-of-possession key by its Key ID.
For details, see section 3.4 of RFC 8747.
Implementations§
source§impl ProofOfPossessionKey
impl ProofOfPossessionKey
sourcepub fn key_id(&self) -> &ByteString
pub fn key_id(&self) -> &ByteString
Returns the key ID of this PoP key, cloning it if necessary. Note that the returned key ID may be empty if no key ID was present in the key.
Example
let key = CoseKeyBuilder::new_symmetric_key(vec![0; 5]).key_id(vec![0xDC, 0xAF]).build();
let pop_key = ProofOfPossessionKey::from(key);
assert_eq!(pop_key.key_id().to_vec(), vec![0xDC, 0xAF]);
Trait Implementations§
source§impl Clone for ProofOfPossessionKey
impl Clone for ProofOfPossessionKey
source§fn clone(&self) -> ProofOfPossessionKey
fn clone(&self) -> ProofOfPossessionKey
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ProofOfPossessionKey
impl Debug for ProofOfPossessionKey
source§impl<'_derivative_strum> From<&'_derivative_strum ProofOfPossessionKey> for &'static str
impl<'_derivative_strum> From<&'_derivative_strum ProofOfPossessionKey> for &'static str
source§fn from(x: &'_derivative_strum ProofOfPossessionKey) -> &'static str
fn from(x: &'_derivative_strum ProofOfPossessionKey) -> &'static str
source§impl From<CoseEncrypt0> for ProofOfPossessionKey
impl From<CoseEncrypt0> for ProofOfPossessionKey
source§fn from(enc: CoseEncrypt0) -> Self
fn from(enc: CoseEncrypt0) -> Self
source§impl From<CoseKey> for ProofOfPossessionKey
impl From<CoseKey> for ProofOfPossessionKey
source§impl From<ProofOfPossessionKey> for &'static str
impl From<ProofOfPossessionKey> for &'static str
source§fn from(x: ProofOfPossessionKey) -> &'static str
fn from(x: ProofOfPossessionKey) -> &'static str
source§impl From<Vec<u8, Global>> for ProofOfPossessionKey
impl From<Vec<u8, Global>> for ProofOfPossessionKey
source§fn from(kid: ByteString) -> Self
fn from(kid: ByteString) -> Self
source§impl PartialEq<ProofOfPossessionKey> for ProofOfPossessionKey
impl PartialEq<ProofOfPossessionKey> for ProofOfPossessionKey
source§fn eq(&self, other: &ProofOfPossessionKey) -> bool
fn eq(&self, other: &ProofOfPossessionKey) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl ToCborMap for ProofOfPossessionKey
impl ToCborMap for ProofOfPossessionKey
source§fn serialize_into<W>(self, writer: W) -> Result<(), Error<W::Error>>where
Self: Sized,
W: Write,
W::Error: Debug,
fn serialize_into<W>(self, writer: W) -> Result<(), Error<W::Error>>where Self: Sized, W: Write, W::Error: Debug,
writer
. Read moresource§fn deserialize_from<R>(reader: R) -> Result<Self, Error<R::Error>>where
Self: Sized,
R: Read,
R::Error: Debug,
fn deserialize_from<R>(reader: R) -> Result<Self, Error<R::Error>>where Self: Sized, R: Read, R::Error: Debug,
reader
— which is expected to be an instance of this type,
represented as a CBOR map bytestring — into an instance of this type. Read more