//! OpenPGP Certificates.
//!
//! Wraps [`sequoia-openpgp::Cert`] and [related functionality].
//!
//! [`sequoia-openpgp::Cert`]: ../../sequoia_openpgp/struct.Cert.html
//! [related functionality]: ../../sequoia_openpgp/cert/index.html
use std::ptr;
use std::slice;
use libc::{c_char, c_int, size_t, time_t};
extern crate sequoia_openpgp as openpgp;
use self::openpgp::{
autocrypt::Autocrypt,
crypto,
types::ReasonForRevocation,
parse::{
PacketParserResult,
Parse,
},
cert::{
CipherSuite,
KeyIter,
CertBuilder,
CertParser,
CertRevocationBuilder,
UserIDBinding,
UserIDBindingIter,
},
};
use crate::error::Status;
use super::fingerprint::Fingerprint;
use super::packet::key::Key;
use super::packet::Packet;
use super::packet::signature::Signature;
use super::packet_pile::PacketPile;
use super::tsk::TSK;
use super::revocation_status::RevocationStatus;
use crate::Maybe;
use crate::RefRaw;
use crate::MoveFromRaw;
use crate::MoveIntoRaw;
use crate::MoveResultIntoRaw;
use crate::maybe_time;
/// An OpenPGP Certificate.
///
/// A Certificate (see [RFC 4880, section 11.1]) can be used to verify
/// signatures and encrypt data. It can be stored in a keystore and
/// uploaded to keyservers.
///
/// Certs are always canonicalized in the sense that only elements
/// (user id, user attribute, subkey) with at least one valid
/// self-signature are preserved. Also, invalid self-signatures are
/// dropped. The self-signatures are sorted so that the newest
/// self-signature comes first. User IDs are sorted so that the first
/// `UserID` is the primary User ID. Third-party certifications are
/// *not* validated, as the keys are not available; they are simply
/// passed through as is.
///
/// [RFC 4880, section 11.1]: https://tools.ietf.org/html/rfc4880#section-11.1
#[crate::ffi_wrapper_type(
prefix = "pgp_", name = "cert",
derive = "Clone, Debug, Display, PartialEq, Parse, Serialize")]
pub struct Cert(openpgp::Cert);
/// Returns the first Cert found in `m`.
///
/// Consumes `m`.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn pgp_cert_from_packet_pile(errp: Option<&mut *mut crate::error::Error>,
m: *mut PacketPile)
-> Maybe<Cert> {
openpgp::Cert::from_packet_pile(m.move_from_raw()).move_into_raw(errp)
}
/// Returns the first Cert found in the packet parser.
///
/// Consumes the packet parser result.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn pgp_cert_from_packet_parser(errp: Option<&mut *mut crate::error::Error>,
ppr: *mut PacketParserResult)
-> Maybe<Cert>
{
let ppr = ffi_param_move!(ppr);
openpgp::Cert::from_packet_parser(*ppr).move_into_raw(errp)
}
/// Merges `other` into `cert`.
///
/// If `other` is a different key, then nothing is merged into
/// `cert`, but `cert` is still canonicalized.
///
/// Consumes `cert` and `other`.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C"
fn pgp_cert_merge(errp: Option<&