#[non_exhaustive]pub enum Decryptor {
Passphrase(PassphraseDecryptor),
PrivateKey(PrivateKeyDecryptor),
}Expand description
Type-safe entry point for decryption.
Decryptor::open reads the .fcr header without cryptographic work and
returns the variant that matches the file’s recipient kind. Each variant
takes only the credentials it can use:
Decryptor::Passphrasetakes a passphrase.Decryptor::PrivateKeytakes aPrivateKeyplus its unlock passphrase.
A mismatched-credential call — e.g. trying to decrypt a passphrase-sealed
file with a PrivateKey — is therefore a compile error rather than a
runtime CryptoError::DecryptorModeMismatch failure.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Passphrase(PassphraseDecryptor)
File is sealed with a passphrase. Decrypt via
PassphraseDecryptor::decrypt.
PrivateKey(PrivateKeyDecryptor)
File is sealed to one or more public-key recipients. Decrypt
via PrivateKeyDecryptor::decrypt.
Implementations§
Source§impl Decryptor
impl Decryptor
Sourcepub fn open(input: impl AsRef<Path>) -> Result<Self, CryptoError>
pub fn open(input: impl AsRef<Path>) -> Result<Self, CryptoError>
Probes the .fcr header (cheap structural read; no recipient
unwrap, no MAC, no payload bytes touched) and returns the
matching variant.
§Errors
Returns CryptoError::InputPath if input does not exist and
CryptoError::InvalidInput if input is a directory. Files that do
not contain a FerroCrypt header return CryptoError::InvalidFormat
with FormatDefect::BadMagic. Malformed headers, unsupported
versions, unknown critical recipients, and illegal recipient mixes return
their corresponding CryptoError or FormatDefect variants.
Sourcepub fn open_with_limits(
input: impl AsRef<Path>,
header_read_limits: HeaderReadLimits,
) -> Result<Self, CryptoError>
pub fn open_with_limits( input: impl AsRef<Path>, header_read_limits: HeaderReadLimits, ) -> Result<Self, CryptoError>
Same as Decryptor::open but uses the supplied
HeaderReadLimits for the structural header read instead of
the conservative defaults.
Callers handling files whose recipient strings, recipient
counts, or header lengths legitimately exceed the defaults
(for example, forward-compatible files with larger future recipient
bodies) should construct a HeaderReadLimits via the builder
methods and pass it here. The same limits are stashed on the
returned variant so the second header read inside
PassphraseDecryptor::decrypt / PrivateKeyDecryptor::decrypt
uses them too — callers do not need to set them twice.
§Errors
Returns the same errors as Decryptor::open, but applies the supplied
HeaderReadLimits during structural header parsing.