pub struct Cred {
pub session: KeyRing,
pub persistent: Option<KeyRing>,
pub description: String,
pub specifiers: Option<(String, String)>,
}
Expand description
Representation of a keyutils credential.
Since the CredentialBuilderApi::build method does not provide an initial secret, and it is impossible to have 0-length keys, this representation holds a linux_keyutils::KeyRing instead of a linux_keyutils::Key.
The added benefit of this approach is that any call to get_password before set_password is done will result in a proper error as the key does not exist until set_password is called.
Fields§
§session: KeyRing
Host session keyring
persistent: Option<KeyRing>
Host persistent keyring
description: String
Description of the key entry
specifiers: Option<(String, String)>
Specifiers for the entry, if any
Implementations§
Source§impl Cred
impl Cred
Sourcepub fn build_from_specifiers(
target: Option<&str>,
delimiters: &[String; 3],
service_no_dividers: bool,
service: &str,
user: &str,
) -> Result<Self>
pub fn build_from_specifiers( target: Option<&str>, delimiters: &[String; 3], service_no_dividers: bool, service: &str, user: &str, ) -> Result<Self>
Create the platform credential for a Keyutils entry.
An explicit target string is interpreted as the description to use for the entry.
If none is provided, then we concatenate the user and service in the string
{delimiters[0]}{user}{delimiters[1]}{service}{delimiters[2]}
.
Trait Implementations§
Source§impl CredentialApi for Cred
impl CredentialApi for Cred
Source§fn set_secret(&self, secret: &[u8]) -> Result<()>
fn set_secret(&self, secret: &[u8]) -> Result<()>
See the keyring-core API docs.
This will overwrite the entry if it already exists since
it’s using add_key
under the hood.
Returns an Invalid error if the password is empty, because keyutils keys cannot have empty values.
Source§fn get_secret(&self) -> Result<Vec<u8>>
fn get_secret(&self) -> Result<Vec<u8>>
See the keyring-core API docs.
This requires a call to Key::read
.
Source§fn delete_credential(&self) -> Result<()>
fn delete_credential(&self) -> Result<()>
See the keyring-core API docs.
Under the hood this uses Key::invalidate
to immediately
invalidate the key and prevent any further successful
searches.
Note that the keyutils implementation uses caching, and the caches take some time to clear, so get_password may find a key that has been invalidated if it’s called within milliseconds of the invalidation in the same process that deleted the key.
Source§fn get_credential(&self) -> Result<Option<Arc<Credential>>>
fn get_credential(&self) -> Result<Option<Arc<Credential>>>
See the keyring-core API docs.
Since this store has no ambiguity, entries are wrappers.
Source§fn get_specifiers(&self) -> Option<(String, String)>
fn get_specifiers(&self) -> Option<(String, String)>
See the keyring-core API docs.
Specifiers are remembered at creation time if the description was not custom.