pub struct KeyRing { /* private fields */ }Expand description
Holds the master key and derives purpose-specific subkeys via HKDF-SHA256. Key material is zeroized on drop.
Implementations§
Source§impl KeyRing
impl KeyRing
Sourcepub fn new(master: Option<&[u8]>) -> Self
pub fn new(master: Option<&[u8]>) -> Self
Creates a keyring from master, or generates 32 random bytes when
None is given.
Sourcepub fn subkey(&self, info: &str) -> Result<Zeroizing<[u8; 32]>>
pub fn subkey(&self, info: &str) -> Result<Zeroizing<[u8; 32]>>
Derives a 32-byte subkey via HKDF-SHA256 with the given info string.
Sourcepub fn encrypt(
&self,
data: &[u8],
algorithm: EncryptionAlgorithm,
) -> Result<Vec<u8>>
pub fn encrypt( &self, data: &[u8], algorithm: EncryptionAlgorithm, ) -> Result<Vec<u8>>
Encrypts with the default emoji-encryption subkey. Output is
nonce(12) || ciphertext.
Sourcepub fn decrypt(
&self,
data: &[u8],
algorithm: EncryptionAlgorithm,
) -> Result<Vec<u8>>
pub fn decrypt( &self, data: &[u8], algorithm: EncryptionAlgorithm, ) -> Result<Vec<u8>>
Decrypts a nonce(12) || ciphertext payload produced by
KeyRing::encrypt. Wrong keys and tampering both surface as
MeshError::Crypto.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KeyRing
impl RefUnwindSafe for KeyRing
impl Send for KeyRing
impl Sync for KeyRing
impl Unpin for KeyRing
impl UnsafeUnpin for KeyRing
impl UnwindSafe for KeyRing
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