Keys

Struct Keys 

Source
pub struct Keys<'names> { /* private fields */ }
Expand description

Contains the key pairs and their names. This struct is to use the key pairs and to retrieve them. It can also be used to create new key pairs.

Implementations§

Source§

impl<'names> Keys<'names>

Source

pub fn new(priv_key_name: &'names str, pub_key_name: &'names str) -> Self

Creates key pairs.

§Parameters
  • priv_key_name & pub_key_name: The name of the keys. If the keys are saved to disk with self.write_to_disk the values for these variables will be the file name.
Source

pub fn retrieve_keys( priv_key_path: &'names str, password: &str, pub_key_path: &'names str, ) -> AnyResult<Self>

Will read the PEM encoded public and private keys and return Self. If you only want a specific key look at their respective function.

  • retrieve_private_key
  • retrieve_public_key
§Parameters
  • priv_key: Path to private key file.
  • password: The password used to encrypt the private key.
  • pub_key: Path to public key file.
Source

pub fn retrieve_private_key( priv_key_path: &'names str, password: &str, ) -> AnyResult<Self>

Source§

impl Keys<'_>

Source

pub fn write_to_disk(&self, priv_key_pass: &str, folder: &str) -> AnyResult<()>

Will further encrypt the self.priv_key before writing it to disk. Both keys will be PEM encoded.

§Parameters
  • priv_key_pass: The password used to encrypt the private key.
  • folder: The folder to write the keys to. If left empty will default to cwd.
Source

pub fn seal(&self, plaintext: &[u8]) -> AnyResult<Vec<u8>>

Source

pub fn unseal(&self, ciphertext: &[u8]) -> AnyResult<Vec<u8>>

Auto Trait Implementations§

§

impl<'names> Freeze for Keys<'names>

§

impl<'names> RefUnwindSafe for Keys<'names>

§

impl<'names> Send for Keys<'names>

§

impl<'names> Sync for Keys<'names>

§

impl<'names> Unpin for Keys<'names>

§

impl<'names> UnwindSafe for Keys<'names>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V