[−][src]Struct pwbox::Eraser
Helper structure to convert password-encrypted boxes to a serializable format and back.
Examples
let mut eraser = Eraser::new(); // Register separate KDFs and ciphers eraser.add_kdf::<SomeKdf>("some-kdf"); eraser.add_cipher::<SomeCipher>("some-cipher"); // Add a suite. eraser.add_suite::<SomeSuite>(); // Erase a `PwBox`. let pwbox = SomeSuite::build_box(&mut thread_rng()) .seal("password", b"some data") .unwrap(); let erased = eraser.erase(&pwbox).unwrap(); // `erased` can now be serialized somewhere, e.g., in JSON format. // Restore a `PwBox`. let restored = eraser.restore(&erased).unwrap(); assert_eq!(&*restored.open("password").unwrap(), b"some data");
Implementations
impl Eraser
[src]
pub fn new() -> Self
[src]
Creates an Eraser
with no ciphers or KDFs.
pub fn add_cipher<C>(&mut self, cipher_name: &str) -> &mut Self where
C: Cipher,
[src]
C: Cipher,
Adds a cipher.
Panics
Panics if the cipher is already registered under a different name, or if cipher_name
is already registered.
pub fn add_kdf<K>(&mut self, kdf_name: &str) -> &mut Self where
K: DeriveKey + DeserializeOwned + Default,
[src]
K: DeriveKey + DeserializeOwned + Default,
Adds a key derivation function.
Panics
Panics if the KDF is already registered under a different name, or if kdf_name
is already registered.
pub fn add_suite<S: Suite>(&mut self) -> &mut Self
[src]
Adds all KDFs and ciphers from the specified Suite
.
Panics
This method panics if any KDF or cipher in the suite (or its name) have been registered previously. A panic is also raised if the suite has not registered its recommended cipher or KDF.
pub fn erase<K, C>(
&self,
pwbox: &PwBox<K, C>
) -> Result<ErasedPwBox, EraseError> where
K: DeriveKey + Serialize,
C: Cipher,
[src]
&self,
pwbox: &PwBox<K, C>
) -> Result<ErasedPwBox, EraseError> where
K: DeriveKey + Serialize,
C: Cipher,
Converts a pwbox
into serializable form.
pub fn restore(&self, erased: &ErasedPwBox) -> Result<RestoredPwBox, Error>
[src]
Restores a PwBox
from the serialized form.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Eraser
impl !Send for Eraser
impl !Sync for Eraser
impl Unpin for Eraser
impl !UnwindSafe for Eraser
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,