Skip to main content

KeySelector

Struct KeySelector 

Source
pub struct KeySelector {
    pub token: TokenSelector,
    pub key_unique_id: Option<String>,
    pub key_label: Option<String>,
    pub key_id: Option<String>,
    pub key_url: Option<String>,
}
Expand description

Selects keys with the specified identifier.

Fields§

§token: TokenSelector

Selects a token.

§key_unique_id: Option<String>

Selects keys with the specified unique ID.

An object’s ID corresponds to its unique ID attribute, which was introduced in PKCS#11 3.0 in 2020.

The value of the restriction is compared to both the key’s raw unique ID and the unique ID encoded in hex. This allows matching unique IDs with non-printable characters.

If a key does not have a unique ID, then it doesn’t match a restriction on the key’s unique ID.

§key_label: Option<String>

Selects keys with the specified label.

An key’s label correspond to its label attribute, which is normally set by the user when the key is created.

The value of the restriction is compared to both the key’s raw label and the label encoded in hex. This allows matching labels with non-printable characters.

If a key does not have a label, then it doesn’t match a restriction on the label.

§key_id: Option<String>

Selects keys with the specified ID.

An object’s ID is usually set by the application when the key is created.

The value of the restriction is compared to both the key’s raw ID and the ID encoded in hex. This allows matching IDs with non-printable characters.

If a key does not have an ID, then it doesn’t match a restriction on the key’s ID.

§key_url: Option<String>

Selects keys with the specified URL.

An object’s URL is usually set by the application when the key is created.

The value of the restriction is compared to both the key’s raw URL and the URL encoded in hex. This allows matching URLs with non-printable characters.

If a key does not have a URL, then it doesn’t match a restriction on the key’s URL.

Implementations§

Source§

impl KeySelector

Source

pub fn unconstrained() -> Self

Returns an unconstrained KeySelector.

This matches all keys on all tokens.

Source

pub fn from_token_selector(selector: TokenSelector) -> Self

Creates a KeySelector from a TokenSelector.

Source

pub fn from_key_label(key_label: impl Into<String>) -> Self

Creates a KeySelector for a specific label.

Source

pub fn from_key_id(key_id: impl Into<String>) -> Self

Creates a KeySelector for a specific key ID.

Source

pub fn has_backend_restrictions(&self) -> bool

Returns true if the selector has any restrictions on the backend.

A selector without restrictions matches all backends.

Source

pub fn has_token_restrictions(&self) -> bool

Returns true if the selector has any restrictions on the token.

A selector without restrictions matches all tokens.

Source

pub fn has_key_restrictions(&self) -> bool

Returns true if the selector has any restrictions on the key.

A selector without restrictions matches all keys.

Source

pub fn has_restrictions(&self) -> bool

Returns true if the selector has any restrictions.

A selector without restrictions matches everything.

Source

pub fn backend(&self) -> Option<&str>

Returns the backend restriction, if any.

Source

pub fn backend_matches(&self, backend: &Backend) -> bool

Returns true if the selector matches the backend.

If the selector does not restrict the backend, this returns true.

Source

pub fn slot(&self) -> Option<u64>

Returns the slot restriction, if any.

Source

pub fn slot_matches(&self, slot: u64) -> bool

Returns true if the selector matches the specified slot.

If the selector does not restrict the slot, this returns true.

Source

pub fn token_label(&self) -> Option<&str>

Returns the token label restriction, if any.

Source

pub fn token_label_matches(&self, label: &str) -> bool

Returns true if the selector matches the specified token’s label.

If the selector does not restrict the token’s label, this returns true.

Source

pub fn token_serial_number(&self) -> Option<&str>

Returns the token serial number restriction, if any.

Source

pub fn token_serial_number_matches(&self, serial_number: &str) -> bool

Returns true if the selector matches the specified token’s serial number.

If the selector does not restrict the token’s serial number, this returns true.

Source

pub fn key_unique_id(&self) -> Option<&str>

Returns the key unique ID restriction, if any.

Source

pub fn key_unique_id_matches(&self, key_unique_id: Option<&[u8]>) -> bool

Returns true if the selector matches the specified key’s unique ID.

If the selector does not restrict the key’s unique ID, this returns true.

The value is compared to the restriction as is. If that doesn’t match, the value is hex encoded and compared to the restriction. This allows matching on unique IDs with non-printable characters.

Source

pub fn key_label(&self) -> Option<&str>

Returns the key label restriction, if any.

Source

pub fn key_label_matches(&self, key_label: Option<&[u8]>) -> bool

Returns true if the selector matches the specified key’s label.

If the selector does not restrict the key’s label, then this returns true.

The value is compared to the restriction as is. If that doesn’t match, the value is hex encoded and compared to the restriction. This allows matching on labels with non-printable characters.

Source

pub fn key_id(&self) -> Option<&str>

Returns the key ID restriction, if any.

Source

pub fn key_id_matches(&self, key_id: Option<&[u8]>) -> bool

Returns true if the selector matches the specified key ID.

If the selector does not restrict the key ID, then this returns true.

The value is compared to the restriction as is. If that doesn’t match, the value is hex encoded and compared to the restriction. This allows matching on key IDs with non-printable characters.

Source

pub fn key_url(&self) -> Option<&str>

Returns the key URL restriction, if any.

Source

pub fn key_url_matches(&self, key_url: Option<&[u8]>) -> bool

Returns true if the selector matches the specified key URL.

If the selector does not restrict the key URL, then this returns true.

The value is compared to the restriction as is. If that doesn’t match, the value is hex encoded and compared to the restriction. This allows matching on URLs with non-printable characters.

Source

pub fn args(&self) -> String

Returns the argument and value as a string, e.g., “–slot 1”.

Trait Implementations§

Source§

impl Clone for KeySelector

Source§

fn clone(&self) -> KeySelector

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for KeySelector

Source§

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

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

impl From<&Token> for KeySelector

Source§

fn from(token: &Token) -> KeySelector

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.