pub struct FileHeader { /* private fields */ }Expand description
Complete v1 file header.
The struct holds only the header’s actual information content; the layout artifacts of the serialized form (magic, version byte, length fields) are computed during (de)serialization and never stored.
Serialized layout:
| field | size |
|---|---|
| magic (“SHADOW”) | 6 bytes |
| version (1) | 1 byte |
| header_length | 4 bytes |
| salt | 16 bytes |
| kdf_memory | 4 bytes |
| kdf_iterations | 4 bytes |
| kdf_parallelism | 4 bytes |
| kdf_key_length | 1 byte |
| content_nonce | 24 bytes |
| filename_nonce | 24 bytes |
| filename_ciphertext_length | 2 bytes |
| filename_ciphertext | variable |
Implementations§
Source§impl FileHeader
impl FileHeader
pub fn new( salt: [u8; 16], kdf_params: KeyDerivationParams, content_nonce: [u8; 24], filename_nonce: [u8; 24], filename_ciphertext: Vec<u8>, ) -> Self
Sourcepub fn header_length(&self) -> usize
pub fn header_length(&self) -> usize
Total length of this header’s serialized form.
pub fn serialize(&self) -> Vec<u8> ⓘ
pub fn try_deserialize(bytes: &[u8]) -> Result<FileHeader, HeaderError>
pub fn salt(&self) -> &[u8; 16]
Sourcepub fn kdf_params(&self) -> &KeyDerivationParams
pub fn kdf_params(&self) -> &KeyDerivationParams
The key derivation parameters recorded in this header.
pub fn content_nonce(&self) -> &[u8; 24]
pub fn filename_nonce(&self) -> &[u8; 24]
pub fn filename_ciphertext(&self) -> &[u8] ⓘ
Sourcepub fn decrypt_content(
&self,
ciphertext: &[u8],
key: &SecureKey,
) -> Result<SecureBytes, FileError>
pub fn decrypt_content( &self, ciphertext: &[u8], key: &SecureKey, ) -> Result<SecureBytes, FileError>
Decrypts a content ciphertext under this header’s content nonce.
Sourcepub fn decrypt_filename(
&self,
key: &SecureKey,
) -> Result<SecureString, FileError>
pub fn decrypt_filename( &self, key: &SecureKey, ) -> Result<SecureString, FileError>
Decrypts the original filename stored in this header.
Trait Implementations§
Source§impl Clone for FileHeader
impl Clone for FileHeader
Source§fn clone(&self) -> FileHeader
fn clone(&self) -> FileHeader
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 FileHeader
impl RefUnwindSafe for FileHeader
impl Send for FileHeader
impl Sync for FileHeader
impl Unpin for FileHeader
impl UnsafeUnpin for FileHeader
impl UnwindSafe for FileHeader
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