pub struct Shield { /* private fields */ }Expand description
EXPTIME-secure symmetric encryption.
Uses password-derived keys with PBKDF2 and encrypts using a SHA256-based stream cipher with HMAC-SHA256 authentication. Breaking requires 2^256 operations - no shortcut exists.
Key material is securely zeroized from memory when dropped.
Implementations§
Source§impl Shield
impl Shield
Sourcepub fn with_key(key: [u8; 32]) -> Self
pub fn with_key(key: [u8; 32]) -> Self
Create Shield with a pre-shared key (no password derivation).
Sourcepub fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>>
pub fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>>
Encrypt data.
Returns: nonce(16) || ciphertext || mac(16)
§Errors
Returns error if random generation fails.
Sourcepub fn encrypt_with_key(key: &[u8; 32], plaintext: &[u8]) -> Result<Vec<u8>>
pub fn encrypt_with_key(key: &[u8; 32], plaintext: &[u8]) -> Result<Vec<u8>>
Encrypt with explicit key.
Sourcepub fn decrypt(&self, encrypted: &[u8]) -> Result<Vec<u8>>
pub fn decrypt(&self, encrypted: &[u8]) -> Result<Vec<u8>>
Decrypt and verify data.
§Errors
Returns error if MAC verification fails or ciphertext is malformed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Shield
impl RefUnwindSafe for Shield
impl Send for Shield
impl Sync for Shield
impl Unpin for Shield
impl UnwindSafe for Shield
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