//! Autocrypt.
//!
//! This module deals with Autocrypt encoded data (see the [Autocrypt
//! Spec]).
//!
//! [Autocrypt Spec]: https://autocrypt.org/level1.html#openpgp-based-key-data
//!
//! # Scope
//!
//! This implements low-level functionality like encoding and decoding
//! of Autocrypt headers and setup messages. Note: Autocrypt is more
//! than just headers; it requires tight integration with the MUA.
#![doc(html_favicon_url = "https://docs.sequoia-pgp.org/favicon.png")]
#![doc(html_logo_url = "https://docs.sequoia-pgp.org/logo.svg")]
use base64;
use std::convert::TryFrom;
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::Path;
use std::fs::File;
use std::str;
use sequoia_openpgp as openpgp;
use openpgp::armor;
use openpgp::Error;
pub use openpgp::Result;
use openpgp::Packet;
use openpgp::packet::SKESK;
use openpgp::cert::prelude::*;
use openpgp::parse::{
Parse,
PacketParserResult, PacketParser,
};
use openpgp::serialize::Serialize;
use openpgp::serialize::stream::{
Message, LiteralWriter, Encryptor,
};
use openpgp::crypto::Password;
use openpgp::policy::Policy;
use openpgp::types::RevocationStatus;
mod cert;
pub use cert::cert_builder;
/// Version of Autocrypt to use. `Autocrypt::default()` always returns the
/// latest version.
pub enum Autocrypt {
/// Autocrypt <= 1.0.1
V1,
/// Autocrypt version 1.1 (January 2019)
V1_1,
}
impl Default for Autocrypt {
fn default() -> Self { Autocrypt::V1_1 }
}
/// An autocrypt header attribute.
#[derive(Debug, PartialEq)]
pub struct Attribute {
/// Whether the attribute is critical.
pub critical: bool,
/// The attribute's name.
///
/// If the attribute is not critical, the leading underscore has
/// been stripped.
pub key: String,
/// The attribute's value.
pub value: String,
}
/// Whether the data comes from an "Autocrypt" or "Autocrypt-Gossip"
/// header.
#[derive(Debug, PartialEq)]
pub enum AutocryptHeaderType {
/// An "Autocrypt" header.
Sender,
/// An "Autocrypt-Gossip" header.
Gossip,