Cred

Struct Cred 

Source
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

Source

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 Clone for Cred

Source§

fn clone(&self) -> Cred

Returns a duplicate 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 CredentialApi for Cred

Source§

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>>

See the keyring-core API docs.

This requires a call to Key::read.

Source§

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>>>

See the keyring-core API docs.

Since this store has no ambiguity, entries are wrappers.

Source§

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.

Source§

fn as_any(&self) -> &dyn Any

See the keyring-core API docs.

Source§

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

See the keyring-core API docs.

Source§

fn set_password(&self, password: &str) -> Result<(), Error>

Set the entry’s protected data to be the given string. Read more
Source§

fn get_password(&self) -> Result<String, Error>

Retrieve the protected data as a UTF-8 string from the underlying credential. Read more
Source§

fn get_attributes(&self) -> Result<HashMap<String, String>, Error>

Return any store-specific decorations on this entry’s credential. Read more
Source§

fn update_attributes(&self, _: &HashMap<&str, &str>) -> Result<(), Error>

Update the secure store attributes on this entry’s credential. Read more
Source§

impl Debug for Cred

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Cred

§

impl RefUnwindSafe for Cred

§

impl Send for Cred

§

impl Sync for Cred

§

impl Unpin for Cred

§

impl UnwindSafe for Cred

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> 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> 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 = Infallible

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

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

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.