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: TokenSelectorSelects 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
impl KeySelector
Sourcepub fn unconstrained() -> Self
pub fn unconstrained() -> Self
Returns an unconstrained KeySelector.
This matches all keys on all tokens.
Sourcepub fn from_token_selector(selector: TokenSelector) -> Self
pub fn from_token_selector(selector: TokenSelector) -> Self
Creates a KeySelector from a TokenSelector.
Sourcepub fn from_key_label(key_label: impl Into<String>) -> Self
pub fn from_key_label(key_label: impl Into<String>) -> Self
Creates a KeySelector for a specific label.
Sourcepub fn from_key_id(key_id: impl Into<String>) -> Self
pub fn from_key_id(key_id: impl Into<String>) -> Self
Creates a KeySelector for a specific key ID.
Sourcepub fn has_backend_restrictions(&self) -> bool
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.
Sourcepub fn has_token_restrictions(&self) -> bool
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.
Sourcepub fn has_key_restrictions(&self) -> bool
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.
Sourcepub fn has_restrictions(&self) -> bool
pub fn has_restrictions(&self) -> bool
Returns true if the selector has any restrictions.
A selector without restrictions matches everything.
Sourcepub fn backend_matches(&self, backend: &Backend) -> bool
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.
Sourcepub fn slot_matches(&self, slot: u64) -> bool
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.
Sourcepub fn token_label(&self) -> Option<&str>
pub fn token_label(&self) -> Option<&str>
Returns the token label restriction, if any.
Sourcepub fn token_label_matches(&self, label: &str) -> bool
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.
Sourcepub fn token_serial_number(&self) -> Option<&str>
pub fn token_serial_number(&self) -> Option<&str>
Returns the token serial number restriction, if any.
Sourcepub fn token_serial_number_matches(&self, serial_number: &str) -> bool
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.
Sourcepub fn key_unique_id(&self) -> Option<&str>
pub fn key_unique_id(&self) -> Option<&str>
Returns the key unique ID restriction, if any.
Sourcepub fn key_unique_id_matches(&self, key_unique_id: Option<&[u8]>) -> bool
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.
Sourcepub fn key_label_matches(&self, key_label: Option<&[u8]>) -> bool
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.
Sourcepub fn key_id_matches(&self, key_id: Option<&[u8]>) -> bool
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.
Sourcepub fn key_url_matches(&self, key_url: Option<&[u8]>) -> bool
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.