pub struct KeyFile {
pub hostname: Option<String>,
pub username: Option<String>,
pub created: Option<Zoned>,
pub kdf: String,
pub n: u32,
pub r: u32,
pub p: u32,
pub data: Vec<u8>,
pub salt: Vec<u8>,
}Expand description
Key files describe information about repository access keys.
They are usually stored in the repository under /keys/<ID>
Fields§
§hostname: Option<String>Hostname where the key was created
username: Option<String>User which created the key
created: Option<Zoned>Creation time of the key
kdf: StringThe used key derivation function (currently only scrypt)
n: u32Parameter N for scrypt
r: u32Parameter r for scrypt
p: u32Parameter p for scrypt
data: Vec<u8>The key data encrypted by scrypt
salt: Vec<u8>The salt used with scrypt
Implementations§
Source§impl KeyFile
impl KeyFile
Sourcepub fn kdf_key(&self, passwd: &impl AsRef<[u8]>) -> RusticResult<Key>
pub fn kdf_key(&self, passwd: &impl AsRef<[u8]>) -> RusticResult<Key>
Generate a Key using the key derivation function from KeyFile and a given password
§Arguments
passwd- The password to use for the key derivation function
§Errors
- If the parameters of the key derivation function are invalid
- If the output length of the key derivation function is invalid
§Returns
The generated key
Sourcepub fn key_from_data(&self, key: &Key) -> RusticResult<Key>
pub fn key_from_data(&self, key: &Key) -> RusticResult<Key>
Sourcepub fn key_from_password(&self, passwd: &impl AsRef<[u8]>) -> RusticResult<Key>
pub fn key_from_password(&self, passwd: &impl AsRef<[u8]>) -> RusticResult<Key>
Sourcepub fn generate(
key: Key,
passwd: &impl AsRef<[u8]>,
hostname: Option<String>,
username: Option<String>,
with_created: bool,
) -> RusticResult<Self>
pub fn generate( key: Key, passwd: &impl AsRef<[u8]>, hostname: Option<String>, username: Option<String>, with_created: bool, ) -> RusticResult<Self>
Generate a new KeyFile from a given key and password.
§Arguments
key- The key to use for encryptionpasswd- The password to use for the key derivation functionhostname- The hostname to use for theKeyFileusername- The username to use for theKeyFilewith_created- Whether to set the creation time of theKeyFileto the current time
§Errors
- If the output length of the key derivation function is invalid
- If the
KeyFilecould not be serialized
§Returns
The generated KeyFile
Sourcefn from_backend<B: ReadBackend>(be: &B, id: &KeyId) -> RusticResult<Self>
fn from_backend<B: ReadBackend>(be: &B, id: &KeyId) -> RusticResult<Self>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for KeyFile
impl<'de> Deserialize<'de> for KeyFile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for KeyFile
impl StructuralPartialEq for KeyFile
Auto Trait Implementations§
impl Freeze for KeyFile
impl RefUnwindSafe for KeyFile
impl Send for KeyFile
impl Sync for KeyFile
impl Unpin for KeyFile
impl UnsafeUnpin for KeyFile
impl UnwindSafe for KeyFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more