pub struct WalEncryptionKey { /* private fields */ }Expand description
AES-256-GCM key: exactly 32 bytes.
Implementations§
Source§impl WalEncryptionKey
impl WalEncryptionKey
Sourcepub fn from_bytes(key: &[u8; 32]) -> Self
pub fn from_bytes(key: &[u8; 32]) -> Self
Create from a 32-byte key.
Sourcepub fn from_file(path: &Path) -> Result<Self>
pub fn from_file(path: &Path) -> Result<Self>
Load key from a file (must contain exactly 32 bytes).
Sourcepub fn encrypt(
&self,
lsn: u64,
header_bytes: &[u8; 30],
plaintext: &[u8],
) -> Result<Vec<u8>>
pub fn encrypt( &self, lsn: u64, header_bytes: &[u8; 30], plaintext: &[u8], ) -> Result<Vec<u8>>
Encrypt a payload. Returns ciphertext + auth_tag (16 bytes appended).
lsn: used to derive a deterministic nonceheader_bytes: used as AAD (additional authenticated data)plaintext: the payload to encrypt
Sourcepub fn decrypt(
&self,
lsn: u64,
header_bytes: &[u8; 30],
ciphertext: &[u8],
) -> Result<Vec<u8>>
pub fn decrypt( &self, lsn: u64, header_bytes: &[u8; 30], ciphertext: &[u8], ) -> Result<Vec<u8>>
Decrypt a payload. Input is ciphertext + auth_tag (16 bytes at end).
lsn: must match the LSN used during encryptionheader_bytes: must match the header used during encryption (AAD)ciphertext: the encrypted payload (includes 16-byte auth tag)
Trait Implementations§
Source§impl Clone for WalEncryptionKey
impl Clone for WalEncryptionKey
Source§fn clone(&self) -> WalEncryptionKey
fn clone(&self) -> WalEncryptionKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WalEncryptionKey
impl RefUnwindSafe for WalEncryptionKey
impl Send for WalEncryptionKey
impl Sync for WalEncryptionKey
impl Unpin for WalEncryptionKey
impl UnsafeUnpin for WalEncryptionKey
impl UnwindSafe for WalEncryptionKey
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