Skip to main content

KeyFile

Struct KeyFile 

Source
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: String

The used key derivation function (currently only scrypt)

§n: u32

Parameter N for scrypt

§r: u32

Parameter r for scrypt

§p: u32

Parameter p for scrypt

§data: Vec<u8>

The key data encrypted by scrypt

§salt: Vec<u8>

The salt used with scrypt

Implementations§

Source§

impl KeyFile

Source

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

Source

pub fn key_from_data(&self, key: &Key) -> RusticResult<Key>

Extract a key from the data of the KeyFile using the given key. The key usually should be the key generated by kdf_key()

§Arguments
  • key - The key to use for decryption
§Errors
  • If the data could not be deserialized
§Returns

The extracted key

Source

pub fn key_from_password(&self, passwd: &impl AsRef<[u8]>) -> RusticResult<Key>

Extract a key from the data of the KeyFile using the key from the derivation function in combination with the given password.

§Arguments
  • passwd - The password to use for the key derivation function
§Errors
  • If the parameters of the key derivation function are invalid
§Returns

The extracted key

Source

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 encryption
  • passwd - The password to use for the key derivation function
  • hostname - The hostname to use for the KeyFile
  • username - The username to use for the KeyFile
  • with_created - Whether to set the creation time of the KeyFile to the current time
§Errors
  • If the output length of the key derivation function is invalid
  • If the KeyFile could not be serialized
§Returns

The generated KeyFile

Source

fn from_backend<B: ReadBackend>(be: &B, id: &KeyId) -> RusticResult<Self>

Get a KeyFile from the backend

§Arguments
  • be - The backend to use
  • id - The id of the KeyFile
§Errors
  • If the KeyFile could not be deserialized/read from the backend
§Returns

The KeyFile read from the backend

Trait Implementations§

Source§

impl Debug for KeyFile

Source§

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

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

impl<'de> Deserialize<'de> for KeyFile

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for KeyFile

Source§

impl PartialEq for KeyFile

Source§

fn eq(&self, other: &KeyFile) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl RepoFile for KeyFile

Source§

const TYPE: FileType = FileType::Key

The FileType associated with the repository file
Source§

const ENCRYPTED: bool = false

Indicate whether the files are stored encrypted
Source§

type Id = KeyId

The Id type associated with the repository file
Source§

impl Serialize for KeyFile

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for KeyFile

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.