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

source

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

source§

fn clone(&self) -> ProofOfPossessionKey

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ProofOfPossessionKey

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'_derivative_strum> From<&'_derivative_strum ProofOfPossessionKey> for &'static str

source§

fn from(x: &'_derivative_strum ProofOfPossessionKey) -> &'static str

Converts to this type from the input type.
source§

impl From<CoseEncrypt0> for ProofOfPossessionKey

source§

fn from(enc: CoseEncrypt0) -> Self

Converts to this type from the input type.
source§

impl From<CoseKey> for ProofOfPossessionKey

source§

fn from(key: CoseKey) -> Self

Converts to this type from the input type.
source§

impl From<ProofOfPossessionKey> for &'static str

source§

fn from(x: ProofOfPossessionKey) -> &'static str

Converts to this type from the input type.
source§

impl From<Vec<u8, Global>> for ProofOfPossessionKey

source§

fn from(kid: ByteString) -> Self

Converts to this type from the input type.
source§

impl PartialEq<ProofOfPossessionKey> for ProofOfPossessionKey

source§

fn eq(&self, other: &ProofOfPossessionKey) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToCborMap for ProofOfPossessionKey

source§

fn serialize_into<W>(self, writer: W) -> Result<(), Error<W::Error>>where Self: Sized, W: Write, W::Error: Debug,

Serializes this type as a CBOR map bytestring into the given writer. Read more
source§

fn deserialize_from<R>(reader: R) -> Result<Self, Error<R::Error>>where Self: Sized, R: Read, R::Error: Debug,

Deserializes from the given 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
source§

fn to_ciborium_value(&self) -> Value

Converts this type to a CBOR serializable Value using to_cbor_map. Read more
source§

impl TryFrom<ProofOfPossessionKey> for ByteString

§

type Error = WrongSourceTypeError<ProofOfPossessionKey>

The type returned in the event of a conversion error.
source§

fn try_from( value: ProofOfPossessionKey ) -> Result<Self, WrongSourceTypeError<ProofOfPossessionKey>>

Performs the conversion.
source§

impl TryFrom<ProofOfPossessionKey> for CoseEncrypt0

§

type Error = WrongSourceTypeError<ProofOfPossessionKey>

The type returned in the event of a conversion error.
source§

fn try_from( value: ProofOfPossessionKey ) -> Result<Self, WrongSourceTypeError<ProofOfPossessionKey>>

Performs the conversion.
source§

impl TryFrom<ProofOfPossessionKey> for CoseKey

§

type Error = WrongSourceTypeError<ProofOfPossessionKey>

The type returned in the event of a conversion error.
source§

fn try_from( value: ProofOfPossessionKey ) -> Result<Self, WrongSourceTypeError<ProofOfPossessionKey>>

Performs the conversion.
source§

impl StructuralPartialEq for ProofOfPossessionKey

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.