pub struct Decryptor<'a, 'ctx> { /* private fields */ }Expand description
Builder over a decryption operation. Mirrors
Encryptor for symmetry.
Returns a DecryptResult that exposes both the plaintext bytes and
the rich metadata surface (recipient / symenc / file info / protection
info / format) by delegating to the underlying verify-op result.
For the simple “just give me the plaintext” case, prefer
decrypt — it’s a thinner wrapper over rnp_decrypt and avoids the
verify-op overhead.
build consumes the ciphertext twice (see below), so Decryptor only
accepts byte slices. To decrypt from a one-shot stream (a reader that
cannot be rewound), use decrypt_from_input instead.
let result = Decryptor::new(&ctx, &ciphertext).build().unwrap();
let _plaintext = result.plaintext();
let _recipients = result.recipient_count().unwrap();Implementations§
Source§impl<'a, 'ctx> Decryptor<'a, 'ctx>
impl<'a, 'ctx> Decryptor<'a, 'ctx>
pub fn new(ctx: &'ctx Context, ciphertext: &'a [u8]) -> Self
Sourcepub fn build(self) -> Result<DecryptResult<'ctx>>
pub fn build(self) -> Result<DecryptResult<'ctx>>
Execute the decryption, returning the plaintext and rich metadata.
This runs the decryption pipeline twice: once via rnp_decrypt to
extract the plaintext bytes, and once via rnp_op_verify_* to
collect recipient/symenc/file-info metadata. The double pass is
necessary because the verify-op surface doesn’t expose its output
bytes after execute (the output is destroyed with the op).