pub struct ParsedFile(/* private fields */);Expand description
A parsed shadow file of any format version.
Implementations§
Source§impl ParsedFile
impl ParsedFile
Sourcepub fn parse(bytes: &[u8]) -> Result<Self, HeaderError>
pub fn parse(bytes: &[u8]) -> Result<Self, HeaderError>
Parses a serialized shadow file, dispatching on its version byte.
Accepts both complete files and header-only prefixes (at least the
full header must be present); trailing bytes are treated as content
ciphertext. When parsing a header-only prefix, use
ParsedFile::content_decryptor and feed the content bytes
externally — ParsedFile::decrypt needs the complete file.
pub fn version(&self) -> Version
Sourcepub fn header_length(&self) -> usize
pub fn header_length(&self) -> usize
Total length of the file’s serialized header; the content ciphertext starts at this offset.
Sourcepub fn kdf_request(&self) -> KdfRequest
pub fn kdf_request(&self) -> KdfRequest
The key derivation inputs recorded in the file’s header. Untrusted:
validate against resource bounds before calling
ParsedFile::derive_key.
Sourcepub fn derive_key(
&self,
password: &[u8],
) -> Result<(SecureKey, KeyDerivationReport), KeyDerivationError>
pub fn derive_key( &self, password: &[u8], ) -> Result<(SecureKey, KeyDerivationReport), KeyDerivationError>
Derives the file’s encryption key from a password, using the KDF and parameters of the file’s own format version.
Sourcepub fn decrypt(&self, key: &SecureKey) -> Result<PlaintextFile, FileError>
pub fn decrypt(&self, key: &SecureKey) -> Result<PlaintextFile, FileError>
Decrypts the file’s filename and content. Requires the file to have
been parsed from its complete bytes; for streamed decryption use
ParsedFile::content_decryptor.
Sourcepub fn decrypt_filename(
&self,
key: &SecureKey,
) -> Result<SecureString, FileError>
pub fn decrypt_filename( &self, key: &SecureKey, ) -> Result<SecureString, FileError>
Decrypts only the original filename stored in the file’s header.
Sourcepub fn decrypt_metadata(
&self,
key: &SecureKey,
) -> Result<FileMetadata, FileError>
pub fn decrypt_metadata( &self, key: &SecureKey, ) -> Result<FileMetadata, FileError>
Decrypts the file’s metadata stored in the header. Format versions that predate metadata storage (v1, v2) return only the filename.
Sourcepub fn content_decryptor(&self, key: &SecureKey) -> ContentDecryptor<'_>
pub fn content_decryptor(&self, key: &SecureKey) -> ContentDecryptor<'_>
Starts decrypting the file’s content from externally supplied
ciphertext bytes (starting at ParsedFile::header_length), so the
caller controls I/O and memory. Works uniformly across versions:
ContentDecryptor::chunk_len says how to feed the bytes.