//! Autocrypt.
//!
//! This module deals with Autocrypt encoded (see the [Autocrypt Spec]).
//!
//! [Autocrypt Spec]: https://autocrypt.org/level1.html#openpgp-based-key-data
//!
//! # Scope
//!
//! This implements encoding and decoding of Autocrypt headers. Note:
//! Autocrypt is more than just headers; it requires tight integration
//! with the MUA.
extern crate base64;
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::Path;
use std::fs::File;
use std::str;
use crate::armor;
use crate::Error;
use crate::Result;
use crate::Packet;
use crate::packet::SKESK;
use crate::Cert;
use crate::cert::components::Amalgamation;
use crate::parse::{
Parse,
PacketParserResult, PacketParser,
};
use crate::serialize::Serialize;
use crate::serialize::stream::{
Message, LiteralWriter, Encryptor,
};
use crate::crypto::Password;
use crate::policy::Policy;
/// 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 "