Struct aether_lib::identity::Id
source · [−]pub struct Id { /* private fields */ }
Expand description
Primitive to represent and store the identity of a user. Used by a user to store their own identity. Uses asymmetric encryption as the basis for authentication.
Implementations
sourceimpl Id
impl Id
sourcepub fn new() -> Result<Id, AetherError>
pub fn new() -> Result<Id, AetherError>
Generate a new identity
Errors
AetherError::OpenSSLError
- If the RSA key pair could not be generated
sourcepub fn get_private_key_path() -> PathBuf
pub fn get_private_key_path() -> PathBuf
Returns PathBuf
to the private key on the filesystem
sourcepub fn get_public_key_path() -> PathBuf
pub fn get_public_key_path() -> PathBuf
Returns PathBuf
to the public key on the filesystem
sourcepub fn save(&self) -> Result<(), AetherError>
pub fn save(&self) -> Result<(), AetherError>
Save the current identity on the filesystem Saves the public key and the private key in PEM format
sourcepub fn load() -> Result<Id, AetherError>
pub fn load() -> Result<Id, AetherError>
Load an identity from the default location on the filesystem Reads the private key from the default location
sourcepub fn load_or_generate() -> Result<Id, AetherError>
pub fn load_or_generate() -> Result<Id, AetherError>
Try to load the identity from the default location on the filesystem or create a new identity. If a new identity is created, it is stored in the default location
sourcepub fn public_key_to_base64(&self) -> Result<String, AetherError>
pub fn public_key_to_base64(&self) -> Result<String, AetherError>
Convert public key to a base64 encoded string Encodes public key as DER and then encodes DER into base64
sourcepub fn private_key_to_base64(&self) -> Result<String, AetherError>
pub fn private_key_to_base64(&self) -> Result<String, AetherError>
Convert private key to a base64 encoded string Encodes private key as DER and then encodes DER into base64
sourcepub fn public_encrypt(&self, from: &[u8]) -> Result<Vec<u8>, AetherError>
pub fn public_encrypt(&self, from: &[u8]) -> Result<Vec<u8>, AetherError>
Encrypt given bytes using the public key
sourcepub fn private_encrypt(&self, from: &[u8]) -> Result<Vec<u8>, AetherError>
pub fn private_encrypt(&self, from: &[u8]) -> Result<Vec<u8>, AetherError>
Encrypt given bytes using the private key
sourcepub fn public_decrypt(&self, from: &[u8]) -> Result<Vec<u8>, AetherError>
pub fn public_decrypt(&self, from: &[u8]) -> Result<Vec<u8>, AetherError>
Decrypt given bytes using the public key
sourcepub fn private_decrypt(&self, from: &[u8]) -> Result<Vec<u8>, AetherError>
pub fn private_decrypt(&self, from: &[u8]) -> Result<Vec<u8>, AetherError>
Decrypt given bytes using the private key
Trait Implementations
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more