pub struct ParsedFile(Inner);Expand description
A parsed shadow file of any format version.
Tuple Fields§
§0: InnerImplementations§
Source§impl ParsedFile
impl ParsedFile
Sourcepub fn parse(bytes: &[u8]) -> Result<ParsedFile, HeaderError>
pub fn parse(bytes: &[u8]) -> Result<ParsedFile, 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.
Auto Trait Implementations§
impl Freeze for ParsedFile
impl RefUnwindSafe for ParsedFile
impl Send for ParsedFile
impl Sync for ParsedFile
impl Unpin for ParsedFile
impl UnsafeUnpin for ParsedFile
impl UnwindSafe for ParsedFile
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more