//! Streaming decryption and verification.
//!
//! This module provides convenient filters for decryption and
//! verification of OpenPGP messages. It is the preferred interface to
//! process OpenPGP messages. These implementations use constant
//! space.
//!
//! Wraps the streaming parsing functions, see
//! [`sequoia-openpgp::parse::stream`].
//!
//! [`sequoia-openpgp::parse::stream`]: ../../../sequoia_openpgp/parse/stream/index.html
use std::ptr;
use libc::{c_int, c_void, time_t};
extern crate sequoia_openpgp as openpgp;
use self::openpgp::{
crypto::SessionKey,
constants::SymmetricAlgorithm,
packet::{
PKESK,
SKESK,
},
};
use self::openpgp::parse::stream::{
self,
DecryptionHelper,
Decryptor,
VerificationHelper,
Verifier,
DetachedVerifier,
};
use crate::Maybe;
use crate::MoveFromRaw;
use crate::MoveIntoRaw;
use crate::MoveResultIntoRaw;
use crate::RefRaw;
use crate::RefMutRaw;
use crate::maybe_time;
use super::super::{
error::Status,
crypto,
io,
keyid,
tpk::TPK,
packet::signature::Signature,
packet::key::Key,
parse::PacketParser,
revocation_status::RevocationStatus,
};
/// Communicates the message structure to the VerificationHelper.
#[crate::ffi_wrapper_type(prefix = "pgp_", derive = "Debug")]
pub struct MessageStructure<'a>(stream::MessageStructure<'a>);
/// Iterates over the message structure.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn pgp_message_structure_iter(structure: *const MessageStructure)
-> *mut MessageStructureIter {
structure.ref_raw().iter().move_into_raw()
}
/// Iterates over the message structure.
#[crate::ffi_wrapper_type(prefix = "pgp_", derive = "Iterator(MessageLayer)")]
pub struct MessageStructureIter<'a>(stream::MessageStructureIter<'a>);
/// Represents a layer of the message structure.
#[crate::ffi_wrapper_type(prefix = "pgp_", derive = "Debug")]
pub struct MessageLayer<'a>(stream::MessageLayer<'a>);
/// Returns the message layer variant.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn pgp_message_layer_variant(result: *const MessageLayer)
-> c_int
{
use self::stream::MessageLayer::*;
match result.ref_raw() {
Compression { .. } => 1,
Encryption { .. } => 2,
SignatureGroup { .. } => 3,
}
}
/// Decomposes a `MessageLayer::Compression`.
///
/// Returns `true` iff the given value is a
/// `MessageLayer::Compression`, and returns each of the variants
/// members if the corresponding parameter is not `NULL`.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn pgp_message_layer_compression(v: *const MessageLayer,
algo_r: Maybe<u8>)
-> bool
{
use self::stream::MessageLayer::*;
if let Compression { algo } = v.ref_raw() {
if let Some