summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-02-26 14:13:19 +0100
committerNeal H. Walfield <neal@pep.foundation>2020-02-26 14:24:32 +0100
commitffb15aa4567af3152633d07a4598444659a8fbd8 (patch)
tree290b3393716ead89edeb54d6f6e0bb2e992b4cd4
parent7196abb880a84c97116fd08ee0d036d2c1792021 (diff)
openpgp: Add a prelude file to import things related to certificates
- Add `openpgp/src/cert/prelude.rs` to import most types and traits related to certificates. - Use it instead of using the types and traits individually.
-rw-r--r--autocrypt/src/cert.rs5
-rw-r--r--autocrypt/src/lib.rs6
-rw-r--r--examples/guide-exploring-openpgp.rs2
-rw-r--r--guide/src/chapter_01.md12
-rw-r--r--guide/src/chapter_02.md12
-rw-r--r--ipc/examples/gpg-agent-decrypt.rs2
-rw-r--r--ipc/tests/gpg-agent.rs2
-rw-r--r--net/src/wkd.rs3
-rw-r--r--openpgp-ffi/src/cert.rs14
-rw-r--r--openpgp-ffi/src/parse/stream.rs5
-rw-r--r--openpgp/examples/decrypt-with.rs2
-rw-r--r--openpgp/examples/generate-encrypt-decrypt.rs3
-rw-r--r--openpgp/examples/generate-sign-verify.rs3
-rw-r--r--openpgp/examples/web-of-trust.rs2
-rw-r--r--openpgp/src/cert/amalgamation.rs3
-rw-r--r--openpgp/src/cert/builder.rs5
-rw-r--r--openpgp/src/cert/component_iter.rs21
-rw-r--r--openpgp/src/cert/components.rs5
-rw-r--r--openpgp/src/cert/keyiter.rs21
-rw-r--r--openpgp/src/cert/mod.rs40
-rw-r--r--openpgp/src/cert/parser/low_level/grammar.lalrpop2
-rw-r--r--openpgp/src/cert/parser/mod.rs4
-rw-r--r--openpgp/src/cert/prelude.rs55
-rw-r--r--openpgp/src/cert/revoke.rs12
-rw-r--r--openpgp/src/packet/key/mod.rs11
-rw-r--r--openpgp/src/packet/signature/mod.rs3
-rw-r--r--openpgp/src/parse/parse.rs13
-rw-r--r--openpgp/src/parse/stream.rs8
-rw-r--r--openpgp/src/policy.rs7
-rw-r--r--openpgp/src/serialize/cert.rs6
-rw-r--r--openpgp/src/serialize/cert_armored.rs6
-rw-r--r--openpgp/src/serialize/mod.rs2
-rw-r--r--openpgp/src/serialize/stream.rs9
-rw-r--r--sqv/src/sqv.rs3
-rw-r--r--tool/src/commands/inspect.rs2
-rw-r--r--tool/src/commands/key.rs2
-rw-r--r--tool/src/commands/mod.rs2
-rw-r--r--tool/src/sq.rs2
38 files changed, 143 insertions, 174 deletions
diff --git a/autocrypt/src/cert.rs b/autocrypt/src/cert.rs
index b1bef161..4063e97a 100644
--- a/autocrypt/src/cert.rs
+++ b/autocrypt/src/cert.rs
@@ -1,9 +1,6 @@
use sequoia_openpgp as openpgp;
use openpgp::packet;
-use openpgp::cert::{
- CertBuilder,
- CipherSuite,
-};
+use openpgp::cert::prelude::*;
use openpgp::types::{
KeyFlags,
};
diff --git a/autocrypt/src/lib.rs b/autocrypt/src/lib.rs
index cb3f32cf..d8e9d119 100644
--- a/autocrypt/src/lib.rs
+++ b/autocrypt/src/lib.rs
@@ -26,11 +26,7 @@ use openpgp::Error;
pub use openpgp::Result;
use openpgp::Packet;
use openpgp::packet::SKESK;
-use openpgp::Cert;
-use openpgp::cert::components::{
- Amalgamation,
- ValidAmalgamation
-};
+use openpgp::cert::prelude::*;
use openpgp::parse::{
Parse,
PacketParserResult, PacketParser,
diff --git a/examples/guide-exploring-openpgp.rs b/examples/guide-exploring-openpgp.rs
index c6b603dc..2263dfe0 100644
--- a/examples/guide-exploring-openpgp.rs
+++ b/examples/guide-exploring-openpgp.rs
@@ -1,7 +1,7 @@
//! https://sequoia-pgp.org/guide/exploring-openpgp/
extern crate sequoia_openpgp as openpgp;
-use crate::openpgp::cert::components::Amalgamation;
+use crate::openpgp::cert::prelude::*;
use crate::openpgp::parse::Parse;
use crate::openpgp::policy::StandardPolicy as P;
diff --git a/guide/src/chapter_01.md b/guide/src/chapter_01.md
index 75bc6896..b6c05d21 100644
--- a/guide/src/chapter_01.md
+++ b/guide/src/chapter_01.md
@@ -14,6 +14,7 @@ use std::convert::TryInto;
extern crate failure;
extern crate sequoia_openpgp as openpgp;
+use openpgp::cert::prelude::*;
use openpgp::serialize::stream::*;
use openpgp::packet::prelude::*;
use openpgp::parse::stream::*;
@@ -41,7 +42,7 @@ fn main() {
#
# /// Generates an signing-capable key.
# fn generate() -> openpgp::Result<openpgp::Cert> {
-# let (cert, _revocation) = openpgp::cert::CertBuilder::new()
+# let (cert, _revocation) = CertBuilder::new()
# .add_userid("someone@example.org")
# .add_signing_subkey()
# .generate()?;
@@ -162,6 +163,7 @@ create it:
#
# extern crate failure;
# extern crate sequoia_openpgp as openpgp;
+# use openpgp::cert::prelude::*;
# use openpgp::serialize::stream::*;
# use openpgp::packet::prelude::*;
# use openpgp::parse::stream::*;
@@ -189,7 +191,7 @@ create it:
#
/// Generates an signing-capable key.
fn generate() -> openpgp::Result<openpgp::Cert> {
- let (cert, _revocation) = openpgp::cert::CertBuilder::new()
+ let (cert, _revocation) = CertBuilder::new()
.add_userid("someone@example.org")
.add_signing_subkey()
.generate()?;
@@ -310,6 +312,7 @@ implements [`io::Write`], and we simply write the plaintext to it.
#
# extern crate failure;
# extern crate sequoia_openpgp as openpgp;
+# use openpgp::cert::prelude::*;
# use openpgp::serialize::stream::*;
# use openpgp::packet::prelude::*;
# use openpgp::parse::stream::*;
@@ -337,7 +340,7 @@ implements [`io::Write`], and we simply write the plaintext to it.
#
# /// Generates an signing-capable key.
# fn generate() -> openpgp::Result<openpgp::Cert> {
-# let (cert, _revocation) = openpgp::cert::CertBuilder::new()
+# let (cert, _revocation) = CertBuilder::new()
# .add_userid("someone@example.org")
# .add_signing_subkey()
# .generate()?;
@@ -469,6 +472,7 @@ Verified data can be read from this using [`io::Read`].
#
# extern crate failure;
# extern crate sequoia_openpgp as openpgp;
+# use openpgp::cert::prelude::*;
# use openpgp::serialize::stream::*;
# use openpgp::packet::prelude::*;
# use openpgp::parse::stream::*;
@@ -496,7 +500,7 @@ Verified data can be read from this using [`io::Read`].
#
# /// Generates an signing-capable key.
# fn generate() -> openpgp::Result<openpgp::Cert> {
-# let (cert, _revocation) = openpgp::cert::CertBuilder::new()
+# let (cert, _revocation) = CertBuilder::new()
# .add_userid("someone@example.org")
# .add_signing_subkey()
# .generate()?;
diff --git a/guide/src/chapter_02.md b/guide/src/chapter_02.md
index 1d55e6d9..3b95e516 100644
--- a/guide/src/chapter_02.md
+++ b/guide/src/chapter_02.md
@@ -12,6 +12,7 @@ fragments yields the [`openpgp/examples/generate-encrypt-decrypt.rs`].
use std::io::{self, Write};
extern crate sequoia_openpgp as openpgp;
+use openpgp::cert::prelude::*;
use openpgp::crypto::SessionKey;
use openpgp::types::SymmetricAlgorithm;
use openpgp::serialize::stream::*;
@@ -40,7 +41,7 @@ fn main() {
#
# /// Generates an encryption-capable key.
# fn generate() -> openpgp::Result<openpgp::Cert> {
-# let (cert, _revocation) = openpgp::cert::CertBuilder::new()
+# let (cert, _revocation) = CertBuilder::new()
# .add_userid("someone@example.org")
# .add_transport_encryption_subkey()
# .generate()?;
@@ -162,6 +163,7 @@ create it:
# use std::io::{self, Write};
#
# extern crate sequoia_openpgp as openpgp;
+# use openpgp::cert::prelude::*;
# use openpgp::crypto::SessionKey;
# use openpgp::types::SymmetricAlgorithm;
# use openpgp::serialize::stream::*;
@@ -190,7 +192,7 @@ create it:
#
/// Generates an encryption-capable key.
fn generate() -> openpgp::Result<openpgp::Cert> {
- let (cert, _revocation) = openpgp::cert::CertBuilder::new()
+ let (cert, _revocation) = CertBuilder::new()
.add_userid("someone@example.org")
.add_transport_encryption_subkey()
.generate()?;
@@ -312,6 +314,7 @@ implements [`io::Write`], and we simply write the plaintext to it.
# use std::io::{self, Write};
#
# extern crate sequoia_openpgp as openpgp;
+# use openpgp::cert::prelude::*;
# use openpgp::crypto::SessionKey;
# use openpgp::types::SymmetricAlgorithm;
# use openpgp::serialize::stream::*;
@@ -340,7 +343,7 @@ implements [`io::Write`], and we simply write the plaintext to it.
#
# /// Generates an encryption-capable key.
# fn generate() -> openpgp::Result<openpgp::Cert> {
-# let (cert, _revocation) = openpgp::cert::CertBuilder::new()
+# let (cert, _revocation) = CertBuilder::new()
# .add_userid("someone@example.org")
# .add_transport_encryption_subkey()
# .generate()?;
@@ -476,6 +479,7 @@ Decrypted data can be read from this using [`io::Read`].
# use std::io::{self, Write};
#
# extern crate sequoia_openpgp as openpgp;
+# use openpgp::cert::prelude::*;
# use openpgp::crypto::SessionKey;
# use openpgp::types::SymmetricAlgorithm;
# use openpgp::serialize::stream::*;
@@ -504,7 +508,7 @@ Decrypted data can be read from this using [`io::Read`].
#
# /// Generates an encryption-capable key.
# fn generate() -> openpgp::Result<openpgp::Cert> {
-# let (cert, _revocation) = openpgp::cert::CertBuilder::new()
+# let (cert, _revocation) = CertBuilder::new()
# .add_userid("someone@example.org")
# .add_transport_encryption_subkey()
# .generate()?;
diff --git a/ipc/examples/gpg-agent-decrypt.rs b/ipc/examples/gpg-agent-decrypt.rs
index a42803d8..c467f4b0 100644
--- a/ipc/examples/gpg-agent-decrypt.rs
+++ b/ipc/examples/gpg-agent-decrypt.rs
@@ -7,7 +7,7 @@ extern crate clap;
extern crate sequoia_openpgp as openpgp;
extern crate sequoia_ipc as ipc;
-use crate::openpgp::cert::components::Amalgamation;
+use crate::openpgp::cert::prelude::*;
use crate::openpgp::crypto::SessionKey;
use crate::openpgp::types::SymmetricAlgorithm;
use crate::openpgp::packet::key;
diff --git a/ipc/tests/gpg-agent.rs b/ipc/tests/gpg-agent.rs
index 2b15aac7..25b8a711 100644
--- a/ipc/tests/gpg-agent.rs
+++ b/ipc/tests/gpg-agent.rs
@@ -14,7 +14,7 @@ use crate::openpgp::types::{
use crate::openpgp::crypto::SessionKey;
use crate::openpgp::parse::stream::*;
use crate::openpgp::serialize::{Serialize, stream::*};
-use crate::openpgp::cert::{CertBuilder, CipherSuite};
+use crate::openpgp::cert::prelude::*;
use crate::openpgp::policy::Policy;
extern crate sequoia_ipc as ipc;
diff --git a/net/src/wkd.rs b/net/src/wkd.rs
index 0b16ac35..542689bb 100644
--- a/net/src/wkd.rs
+++ b/net/src/wkd.rs
@@ -35,7 +35,7 @@ use crate::openpgp::{
use crate::openpgp::parse::Parse;
use crate::openpgp::serialize::Serialize;
use crate::openpgp::types::HashAlgorithm;
-use crate::openpgp::cert::CertParser;
+use crate::openpgp::cert::prelude::*;
use super::{Result, Error};
@@ -424,7 +424,6 @@ impl Serialize for KeyRing {
#[cfg(test)]
mod tests {
use crate::openpgp::serialize::Serialize;
- use crate::openpgp::cert::CertBuilder;
use super::*;
use self::Variant::*;
diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs
index 988e958f..6624d0dc 100644
--- a/openpgp-ffi/src/cert.rs
+++ b/openpgp-ffi/src/cert.rs
@@ -17,19 +17,7 @@ use self::openpgp::{
PacketParserResult,
Parse,
},
- cert::{
- CipherSuite,
- CertBuilder,
- CertParser,
- CertRevocationBuilder,
- components::{
- KeyIter,
- UserIDBundle,
- UserIDBundleIter,
- ValidAmalgamation,
- ValidKeyIter,
- },
- },
+ cert::prelude::*,
};
use crate::error::Status;
diff --git a/openpgp-ffi/src/parse/stream.rs b/openpgp-ffi/src/parse/stream.rs
index 419c5c5d..3c35f435 100644
--- a/openpgp-ffi/src/parse/stream.rs
+++ b/openpgp-ffi/src/parse/stream.rs
@@ -16,10 +16,7 @@ use libc::{c_int, c_void, time_t};
extern crate sequoia_openpgp as openpgp;
use self::openpgp::{
- cert::components::{
- Amalgamation,
- ValidAmalgamation,
- },
+ cert::prelude::*,
crypto::SessionKey,
types::SymmetricAlgorithm,
packet::{
diff --git a/openpgp/examples/decrypt-with.rs b/openpgp/examples/decrypt-with.rs
index e74bcac2..3c380a91 100644
--- a/openpgp/examples/decrypt-with.rs
+++ b/openpgp/examples/decrypt-with.rs
@@ -8,7 +8,7 @@ use std::io;
extern crate failure;
extern crate sequoia_openpgp as openpgp;
-use crate::openpgp::cert::components::Amalgamation;
+use crate::openpgp::cert::prelude::*;
use crate::openpgp::crypto::{KeyPair, SessionKey};
use crate::openpgp::types::SymmetricAlgorithm;
use crate::openpgp::parse::{
diff --git a/openpgp/examples/generate-encrypt-decrypt.rs b/openpgp/examples/generate-encrypt-decrypt.rs
index 55669c72..4b0d3ff2 100644
--- a/openpgp/examples/generate-encrypt-decrypt.rs
+++ b/openpgp/examples/generate-encrypt-decrypt.rs
@@ -3,6 +3,7 @@
use std::io::{self, Write};
extern crate sequoia_openpgp as openpgp;
+use crate::openpgp::cert::prelude::*;
use crate::openpgp::crypto::SessionKey;
use crate::openpgp::types::SymmetricAlgorithm;
use crate::openpgp::serialize::stream::*;
@@ -31,7 +32,7 @@ fn main() {
/// Generates an encryption-capable key.
fn generate() -> openpgp::Result<openpgp::Cert> {
- let (cert, _revocation) = openpgp::cert::CertBuilder::new()
+ let (cert, _revocation) = CertBuilder::new()
.add_userid("someone@example.org")
.add_transport_encryption_subkey()
.generate()?;
diff --git a/openpgp/examples/generate-sign-verify.rs b/openpgp/examples/generate-sign-verify.rs
index e5f21505..0e9ab2d1 100644
--- a/openpgp/examples/generate-sign-verify.rs
+++ b/openpgp/examples/generate-sign-verify.rs
@@ -4,6 +4,7 @@ use std::io::{self, Write};
extern crate failure;
extern crate sequoia_openpgp as openpgp;
+use crate::openpgp::cert::prelude::*;
use crate::openpgp::serialize::stream::*;
use crate::openpgp::parse::stream::*;
use crate::openpgp::policy::Policy;
@@ -30,7 +31,7 @@ fn main() {
/// Generates an signing-capable key.
fn generate() -> openpgp::Result<openpgp::Cert> {
- let (cert, _revocation) = openpgp::cert::CertBuilder::new()
+ let (cert, _revocation) = CertBuilder::new()
.add_userid("someone@example.org")
.add_signing_subkey()
.generate()?;
diff --git a/openpgp/examples/web-of-trust.rs b/openpgp/examples/web-of-trust.rs
index 123d4a53..ac0ef3db 100644
--- a/openpgp/examples/web-of-trust.rs
+++ b/openpgp/examples/web-of-trust.rs
@@ -11,7 +11,7 @@ use std::env;
extern crate sequoia_openpgp as openpgp;
use crate::openpgp::KeyID;
-use crate::openpgp::cert::CertParser;
+use crate::openpgp::cert::prelude::*;
use crate::openpgp::parse::Parse;
fn main() {
diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs
index fb4b8a9e..db308d72 100644
--- a/openpgp/src/cert/amalgamation.rs
+++ b/openpgp/src/cert/amalgamation.rs
@@ -3,8 +3,7 @@ use std::time;
use std::time::SystemTime;
use crate::{
- Cert,
- cert::components::ComponentBundle,
+ cert::prelude::*,
Error,
packet::Signature,
Result,
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs
index 1a8ea4be..dd38c82f 100644
--- a/openpgp/src/cert/builder.rs
+++ b/openpgp/src/cert/builder.rs
@@ -9,8 +9,7 @@ use crate::packet::{
use crate::Result;
use crate::packet::Signature;
use crate::packet::signature;
-use crate::Cert;
-use crate::cert::CertRevocationBuilder;
+use crate::cert::prelude::*;
use crate::Error;
use crate::crypto::Password;
use crate::types::{
@@ -428,8 +427,6 @@ impl CertBuilder {
#[cfg(test)]
mod tests {
use super::*;
- use crate::cert::components::Amalgamation;
- use crate::cert::components::ValidAmalgamation;
use crate::packet::signature::subpacket::{SubpacketTag, SubpacketValue};
use crate::types::PublicKeyAlgorithm;
use crate::policy::StandardPolicy as P;
diff --git a/openpgp/src/cert/component_iter.rs b/openpgp/src/cert/component_iter.rs
index ec017fe9..25a8db9f 100644
--- a/openpgp/src/cert/component_iter.rs
+++ b/openpgp/src/cert/component_iter.rs
@@ -3,17 +3,7 @@ use std::time::SystemTime;
use crate::{
types::RevocationStatus,
- cert::{
- Cert,
- components::{
- Amalgamation,
- ComponentBundle,
- ComponentBundleIter,
- ComponentAmalgamation,
- ValidAmalgamation,
- ValidComponentAmalgamation,
- },
- },
+ cert::prelude::*,
policy::Policy,
};
@@ -181,18 +171,17 @@ impl<'a, C> ValidComponentIter<'a, C> {
/// ```rust
/// extern crate sequoia_openpgp as openpgp;
/// # use openpgp::Result;
- /// # use openpgp::cert::CertBuilder;
+ /// use openpgp::cert::prelude::*;
/// use openpgp::types::RevocationStatus;
- /// use openpgp::cert::components::{Amalgamation, ValidAmalgamation};
/// use sequoia_openpgp::policy::StandardPolicy;
///
/// # fn main() { f().unwrap(); }
/// # fn f() -> Result<()> {
/// let p = &StandardPolicy::new();
///
- /// # let (cert, _) =
- /// # CertBuilder::general_purpose(None, Some("alice@example.org"))
- /// # .generate()?;
+ /// # let (cert, _) =
+ /// # CertBuilder::general_purpose(None, Some("alice@example.org"))
+ /// # .generate()?;
/// # let timestamp = None;
/// let non_revoked_uas = cert
/// .user_attributes()
diff --git a/openpgp/src/cert/components.rs b/openpgp/src/cert/components.rs
index 01d4a153..2db58947 100644
--- a/openpgp/src/cert/components.rs
+++ b/openpgp/src/cert/components.rs
@@ -49,11 +49,12 @@ pub use super::keyiter::{
pub type KeyBundle<KeyPart, KeyRole> = ComponentBundle<Key<KeyPart, KeyRole>>;
/// A primary key and any associated signatures.
-pub(crate) type PrimaryKeyBundle<KeyPart> =
+pub type PrimaryKeyBundle<KeyPart> =
KeyBundle<KeyPart, key::PrimaryRole>;
/// A subkey and any associated signatures.
-pub type SubkeyBundle<KeyPart> = KeyBundle<KeyPart, key::SubordinateRole>;
+pub type SubkeyBundle<KeyPart>
+ = KeyBundle<KeyPart, key::SubordinateRole>;
/// A key (primary or subkey, public or private) and any associated
/// signatures.
diff --git a/openpgp/src/cert/keyiter.rs b/openpgp/src/cert/keyiter.rs
index 7bf73a5c..db13e8d4 100644
--- a/openpgp/src/cert/keyiter.rs
+++ b/openpgp/src/cert/keyiter.rs
@@ -9,17 +9,7 @@ use crate::{
packet::key,
packet::key::SecretKeyMaterial,
types::KeyFlags,
- cert::{
- Cert,
- components::{
- Amalgamation,
- KeyBundle,
- UnfilteredKeyBundleIter,
- ValidAmalgamation,
- },
- KeyAmalgamation,
- ValidKeyAmalgamation,
- },
+ cert::prelude::*,
policy::Policy,
};
@@ -272,7 +262,7 @@ impl<'a, P: 'a + key::KeyParts> KeyIter<'a, P>
/// ```rust
/// # extern crate sequoia_openpgp as openpgp;
/// # use openpgp::Result;
- /// # use openpgp::cert::CertBuilder;
+ /// # use openpgp::cert::prelude::*;
/// use openpgp::types::RevocationStatus;
/// use sequoia_openpgp::policy::StandardPolicy;
///
@@ -310,7 +300,7 @@ impl<'a, P: 'a + key::KeyParts> KeyIter<'a, P>
/// ```rust
/// # extern crate sequoia_openpgp as openpgp;
/// # use openpgp::Result;
- /// # use openpgp::cert::CertBuilder;
+ /// # use openpgp::cert::prelude::*;
/// use openpgp::types::RevocationStatus;
/// use sequoia_openpgp::policy::StandardPolicy;
///
@@ -363,7 +353,7 @@ impl<'a, P: 'a + key::KeyParts> KeyIter<'a, P>
/// ```rust
/// # extern crate sequoia_openpgp as openpgp;
/// # use openpgp::Result;
- /// # use openpgp::cert::CertBuilder;
+ /// # use openpgp::cert::prelude