summaryrefslogtreecommitdiffstats
path: root/openpgp/src/cert/builder.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-02-06 17:46:56 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-02-06 18:01:33 +0100
commit6953b4f9902f5f524e92a15518d0132fb662704a (patch)
treea02b4e656196a674146709ad42f32f4b295dcac3 /openpgp/src/cert/builder.rs
parent2bd001a81fa53e4f3cbc972f6354c8e3e510d1c7 (diff)
autocrypt: New crate.
- Move the autocrypt-related functionality to a new crate. - Fixes #424.
Diffstat (limited to 'openpgp/src/cert/builder.rs')
-rw-r--r--openpgp/src/cert/builder.rs75
1 files changed, 0 insertions, 75 deletions
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs
index 57bf5597..94d167aa 100644
--- a/openpgp/src/cert/builder.rs
+++ b/openpgp/src/cert/builder.rs
@@ -13,7 +13,6 @@ use crate::Cert;
use crate::cert::CertRevocationBuilder;
use crate::Error;
use crate::crypto::Password;
-use crate::autocrypt::Autocrypt;
use crate::types::{
Features,
HashAlgorithm,
@@ -174,52 +173,6 @@ impl CertBuilder {
}
}
- /// Generates a key compliant to
- /// [Autocrypt](https://autocrypt.org/).
- ///
- /// If no version is given the latest one is used.
- ///
- /// The autocrypt specification requires a UserID. However,
- /// because it can be useful to add the UserID later, it is
- /// permitted to be none.
- pub fn autocrypt<'a, V, U>(version: V, userid: Option<U>)
- -> Self
- where V: Into<Option<Autocrypt>>,
- U: Into<packet::UserID>
- {
- let builder = CertBuilder{
- creation_time: None,
- ciphersuite: match version.into().unwrap_or(Default::default()) {
- Autocrypt::V1 => CipherSuite::RSA3k,
- Autocrypt::V1_1 => CipherSuite::Cv25519,
- },
- primary: KeyBlueprint {
- flags: KeyFlags::default()
- .set_certification(true)
- .set_signing(true),
- expiration: Some(
- time::Duration::new(3 * 52 * 7 * 24 * 60 * 60, 0)),
- },
- subkeys: vec![
- KeyBlueprint {
- flags: KeyFlags::default()
- .set_transport_encryption(true)
- .set_storage_encryption(true),
- expiration: None,
- }
- ],
- userids: vec![],
- user_attributes: vec![],
- password: None,
- };
-
- if let Some(userid) = userid {
- builder.add_userid(userid.into())
- } else {
- builder
- }
- }
-
/// Sets the creation time.
pub fn set_creation_time<T>(mut self, creation_time: T) -> Self
where T: Into<std::time::SystemTime>,
@@ -546,34 +499,6 @@ mod tests {
}
#[test]
- fn autocrypt_v1() {
- let (cert1, _) = CertBuilder::autocrypt(Autocrypt::V1,
- Some("Foo"))
- .generate().unwrap();
- assert_eq!(cert1.primary_key().pk_algo(),
- PublicKeyAlgorithm::RSAEncryptSign);
- assert_eq!(cert1.subkeys().next().unwrap().key().pk_algo(),
- PublicKeyAlgorithm::RSAEncryptSign);
- assert_eq!(cert1.userids().count(), 1);
- }
-
- #[test]
- fn autocrypt_v1_1() {
- let (cert1, _) = CertBuilder::autocrypt(Autocrypt::V1_1,
- Some("Foo"))
- .generate().unwrap();
- assert_eq!(cert1.primary_key().pk_algo(),
- PublicKeyAlgorithm::EdDSA);
- assert_eq!(cert1.subkeys().next().unwrap().key().pk_algo(),
- PublicKeyAlgorithm::ECDH);
- assert_match!(
- crate::crypto::mpis::PublicKey::ECDH {
- curve: crate::types::Curve::Cv25519, ..
- } = cert1.subkeys().next().unwrap().key().mpis());
- assert_eq!(cert1.userids().count(), 1);
- }
-
- #[test]
fn always_certify() {
let p = &P::new();
let (cert1, _) = CertBuilder::new()