//! OpenPGP data types and associated machinery.
//!
//! This crate aims to provide a complete implementation of OpenPGP as
//! defined by [RFC 4880] as well as several extensions (e.g., [RFC
//! 6637], which describes ECC cryptography for OpenPGP). This
//! includes support for unbuffered message processing.
//!
//! A few features that the OpenPGP community considers to be
//! deprecated (e.g., version 3 compatibility) have been left out as
//! well as support for functionality that we consider to be not only
//! completely useless, but also dangerous (e.g., support for
//! [unhashed signature subpackets]). We have also updated some
//! OpenPGP defaults to avoid foot guns (e.g., this crate does not
//! fallback to IDEA, but instead assumes all OpenPGP implementations
//! understand AES). If some functionality is missing, please file a
//! bug report.
//!
//! A non-goal of this crate is support for any sort of high-level,
//! bolted-on functionality. For instance, [RFC 4880] does not define
//! trust models, such as the web of trust, direct trust, or TOFU.
//! Neither does this crate. [RFC 4880] does provide some mechanisms
//! for creating trust models (specifically, UserID certifications),
//! and this crate does expose those mechanisms.
//!
//! We also try hard to avoid dictating how OpenPGP should be used.
//! This doesn't mean that we don't have opinions about how OpenPGP
//! should be used in a number of common scenarios (for instance,
//! message validation). But, in this crate, we refrain from
//! expressing those opinions; we expose an opinionated, high-level
//! interface in the [sequoia-core] and related crates. In our
//! opinion, you should generally use those crates instead of this
//! one.
//!
//! [RFC 4880]: https://tools.ietf.org/html/rfc4880
//! [RFC 6637]: https://tools.ietf.org/html/rfc6637
//! [unhashed signature subpackets]: https://tools.ietf.org/html/rfc4880#section-5.2.3.2
//! [sequoia-core]: ../sequoia_core
extern crate buffered_reader;
// For #[derive(FromPrimitive)]
extern crate num;
#[macro_use]
extern crate num_derive;
extern crate nettle;
extern crate flate2;
extern crate bzip2;
use std::fmt;
use std::ops::Deref;
use std::cell::RefCell;
use std::collections::HashMap;
pub mod armor;
pub mod parse;
pub mod tpk;
pub mod serialize;
mod unknown;
mod signature;
mod key;
mod userid;
mod user_attribute;
mod literal;
mod compressed_data;
mod packet;
mod container;
mod message;
mod iter;
mod hash;
/// The OpenPGP packet tags as defined in [Section 4.3 of RFC 4880].
///
/// [Section 4.3 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-4.3
///
/// The values correspond to the serialized format. The packet types
/// named `UnassignedXX` are not in use as of RFC 4880.
///
/// Use [`Tag::from_numeric`] to translate a numeric value to a symbolic
/// one.
///
/// [`Tag::from_numeric`]: enum.Tag.html#method.from_numeric
#[derive(Debug)]
#[derive(FromPrimitive)]
#[derive(ToPrimitive)]
// We need PartialEq so that assert_eq! works.
#[derive(PartialEq)]
#[derive(Clone, Copy)]
pub enum Tag {
Reserved0 = 0,
/* Public-Key Encrypted Session Key Packet. */
PKESK = 1,
Signature = 2,
/* Symmetric-Key Encrypted Session Key Packet. */
SKESK = 3,
/* One-Pass Signature Packet. */
OnePassSig = 4,
SecretKey = 5,
PublicKey = 6,
SecretSubkey = 7,
CompressedData = 8,
/* Symmetrically Encrypted Data Packet. */
SED = 9,
Marker = 10