//! Public key, public subkey, private key and private subkey packets.
use std::fmt;
use std::mem;
use std::cmp::Ordering;
use time;
use crate::Error;
use crate::crypto::{self, mem::Protected, mpis, hash::Hash, KeyPair};
use crate::packet::Tag;
use crate::packet;
use crate::Packet;
use crate::PublicKeyAlgorithm;
use crate::SymmetricAlgorithm;
use crate::HashAlgorithm;
use crate::constants::Curve;
use crate::crypto::s2k::S2K;
use crate::Result;
use crate::conversions::Time;
use crate::crypto::Password;
use crate::KeyID;
use crate::Fingerprint;
/// Holds a public key, public subkey, private key or private subkey packet.
///
/// See [Section 5.5 of RFC 4880] for details.
///
/// [Section 5.5 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.5
#[derive(PartialEq, Eq, Hash, Clone)]
pub struct Key4 {
/// CTB packet header fields.
pub(crate) common: packet::Common,
/// When the key was created.
creation_time: time::Tm,
/// Public key algorithm of this signature.
pk_algo: PublicKeyAlgorithm,
/// Public key MPIs.
mpis: mpis::PublicKey,
/// Optional secret part of the key.
secret: Option<SecretKey>,
}
impl fmt::Debug for Key4 {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Key4")
.field("fingerprint", &self.fingerprint())
.field("creation_time", &format!("{}", self.creation_time.rfc3339()))
.field("pk_algo", &self.pk_algo)
.field("mpis", &self