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>
impl<'names> Keys<'names>
Sourcepub fn new(priv_key_name: &'names str, pub_key_name: &'names str) -> Self
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 withself.write_to_disk
the values for these variables will be the file name.
Sourcepub fn retrieve_keys(
priv_key_path: &'names str,
password: &str,
pub_key_path: &'names str,
) -> AnyResult<Self>
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.
pub fn retrieve_private_key( priv_key_path: &'names str, password: &str, ) -> AnyResult<Self>
Source§impl Keys<'_>
impl Keys<'_>
Sourcepub fn write_to_disk(&self, priv_key_pass: &str, folder: &str) -> AnyResult<()>
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.
pub fn seal(&self, plaintext: &[u8]) -> AnyResult<Vec<u8>>
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> 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