summaryrefslogtreecommitdiffstats
path: root/openpgp/src/cert
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/src/cert')
-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
10 files changed, 88 insertions, 80 deletions
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::*;
/// use sequoia_openpgp::policy::StandardPolicy;
///
/// # fn main() { f().unwrap(); }
@@ -766,9 +756,8 @@ impl<'a, P: 'a + key::KeyParts> ValidKeyIter<'a, P>
/// ```rust
/// extern crate sequoia_openpgp as openpgp;
/// # use openpgp::Result;
- /// # use openpgp::cert::CertBuilder;
/// use openpgp::types::RevocationStatus;
- /// use openpgp::cert::components::ValidAmalgamation;
+ /// use openpgp::cert::prelude::*;
/// use sequoia_openpgp::policy::StandardPolicy;
///
/// # fn main() { f().unwrap(); }
diff --git a/openpgp/src/cert/mod.rs b/openpgp/src/cert/mod.rs
index 65113950..cd295373 100644
--- a/openpgp/src/cert/mod.rs
+++ b/openpgp/src/cert/mod.rs
@@ -47,20 +47,8 @@ mod amalgamation;
mod builder;
mod bindings;
pub mod components;
-use components::{
- Amalgamation,
- ComponentBundle,
- PrimaryKeyBundle,
- UnfilteredKeyBundleIter,
- UnknownBundleIter,
- ValidAmalgamation,
- ValidComponentAmalgamation,
-};
+use components::ValidAmalgamation;
mod component_iter;
-use component_iter::{
- ComponentIter,
- ValidComponentIter,
-};
mod keyiter;
mod key_amalgamation;
mod parser;
@@ -68,17 +56,6 @@ mod revoke;
pub use self::builder::{CertBuilder, CipherSuite};
-use keyiter::{
- KeyIter,
- ValidKeyIter,
-};
-use key_amalgamation::{
- KeyAmalgamation,
- PrimaryKeyAmalgamation,
- ValidKeyAmalgamation,
- ValidPrimaryKeyAmalgamation,
-};
-
pub use parser::{
KeyringValidity,
KeyringValidator,
@@ -94,6 +71,9 @@ pub use revoke::{
UserIDRevocationBuilder,
};
+pub mod prelude;
+use prelude::*;
+
const TRACE : bool = false;
// Helper functions.
@@ -253,7 +233,7 @@ type UnknownBindings = ComponentBundles<Unknown>;
/// on self signatures can be used to express preferences for
/// algorithms and key management. Furthermore, the key holder's
/// OpenPGP implementation can express its feature set.
-pub trait Preferences<'a, C: 'a>: components::ValidAmalgamation<'a, C> {
+pub trait Preferences<'a, C: 'a>: ValidAmalgamation<'a, C> {
/// Returns symmetric algorithms that the key holder prefers.
///
/// The algorithms are ordered according by the key holder's
@@ -350,9 +330,8 @@ use super::*;
/// ```rust
/// # extern crate sequoia_openpgp as openpgp;
/// # use openpgp::Result;
-/// # use openpgp::cert::components::Amalgamation;
/// # use openpgp::parse::{Parse, PacketParserResult, PacketParser};
-/// use openpgp::{Cert, cert::CertBuilder};
+/// use openpgp::cert::prelude::*;
///
/// # fn main() { f().unwrap(); }
/// # fn f() -> Result<()> {
@@ -556,7 +535,7 @@ impl Cert {
/// # use openpgp::Result;
/// use openpgp::types::RevocationStatus;
/// use openpgp::types::{ReasonForRevocation, SignatureType};
- /// use openpgp::cert::{CipherSuite, CertBuilder};
+ /// use openpgp::cert::prelude::*;
/// use openpgp::crypto::KeyPair;
/// use openpgp::parse::Parse;
/// use sequoia_openpgp::policy::StandardPolicy;
@@ -1494,7 +1473,7 @@ impl<'a> CertAmalgamation<'a> {
/// Returns the amalgamated primary key.
pub fn primary_key(&self)
- -> Result<ValidPrimaryKeyAmalgamation<key::PublicParts>>
+ -> Result<ValidPrimaryKeyAmalgamation<key::PublicParts>>
{
self.cert.primary_key().with_policy(self.policy, self.time)
}
@@ -1535,7 +1514,6 @@ impl<'a> CertAmalgamation<'a> {
#[cfg(test)]
mod test {
use crate::serialize::Serialize;
- use super::components::ValidAmalgamation;
use crate::policy::StandardPolicy as P;
use crate::types::Curve;
use super::*;
@@ -3148,7 +3126,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g=
#[test]
fn keysigning_party() {
- use crate::cert::packet::signature;
+ use crate::packet::signature;
for cs in &[ CipherSuite::Cv25519,
CipherSuite::RSA3k,
diff --git a/openpgp/src/cert/parser/low_level/grammar.lalrpop b/openpgp/src/cert/parser/low_level/grammar.lalrpop
index d8e313e5..1c173180 100644
--- a/openpgp/src/cert/parser/low_level/grammar.lalrpop
+++ b/openpgp/src/cert/parser/low_level/grammar.lalrpop
@@ -7,7 +7,7 @@ use crate::packet::UserAttribute;
use crate::packet::{key, Key};
use crate::packet::Unknown;
use crate::Packet;
-use crate::Cert;
+use crate::cert::prelude::*;
use crate::cert::parser::low_level::lexer;
use crate::cert::parser::low_level::lexer::{Token, Component};
diff --git a/openpgp/src/cert/parser/mod.rs b/openpgp/src/cert/parser/mod.rs
index 7552f4db..f7e24d55 100644
--- a/openpgp/src/cert/parser/mod.rs
+++ b/openpgp/src/cert/parser/mod.rs
@@ -395,7 +395,7 @@ enum PacketSource<'a, I: Iterator<Item=Packet>> {
/// # extern crate sequoia_openpgp as openpgp;
/// # use openpgp::Result;
/// # use openpgp::parse::{Parse, PacketParserResult, PacketParser};
-/// use openpgp::cert::CertParser;
+/// use openpgp::cert::prelude::*;
///
/// # fn main() { f().unwrap(); }
/// # fn f() -> Result<()> {
@@ -512,7 +512,7 @@ impl<'a, I: Iterator<Item=Packet>> CertParser<'a, I> {
/// # extern crate sequoia_openpgp as openpgp;
/// # use openpgp::Result;
/// # use openpgp::parse::{Parse, PacketParser};
- /// use openpgp::cert::CertParser;
+ /// use openpgp::cert::prelude::*;
/// use openpgp::Cert;
/// use openpgp::KeyID;
///
diff --git a/openpgp/src/cert/prelude.rs b/openpgp/src/cert/prelude.rs
new file mode 100644
index 00000000..459d70ee
--- /dev/null
+++ b/openpgp/src/cert/prelude.rs
@@ -0,0 +1,55 @@
+//! Brings most relevant types and traits into scope for working with
+//! certificates.
+//!
+//! Less often used types and types that are more likely to lead to a
+//! naming conflict are not brought into scope.
+//!
+//! Traits are brought into scope anonymously.
+//!
+//! ```
+//! # #![allow(unused_imports)]
+//! # extern crate sequoia_openpgp as openpgp;
+//! use openpgp::cert::prelude::*;
+//! ```
+
+#![allow(unused_imports)]
+pub use crate::cert::{
+ Cert,
+ CertAmalgamation,
+ CertBuilder,
+ CertParser,
+ CertRevocationBuilder,
+ CertValidator,
+ CertValidity,
+ CipherSuite,
+ KeyringValidator,
+ KeyringValidity,
+ Preferences as _,
+ SubkeyRevocationBuilder,
+ UserAttributeRevocationBuilder,
+ UserIDRevocationBuilder,
+ amalgamation::Amalgamation as _,
+ amalgamation::ComponentAmalgamation,
+ amalgamation::ValidAmalgamation as _,
+ amalgamation::ValidComponentAmalgamation,
+ component_iter::ValidComponentIter,
+ components::ComponentIter,
+ components::ComponentBundle,
+ components::ComponentBundleIter,
+ components::KeyBundle,
+ components::PrimaryKeyBundle,
+ components::SubkeyBundle,
+ components::UnfilteredKeyBundleIter,
+ components::UnknownBundle,
+ components::UnknownBundleIter,
+ components::UserAttributeBundle,
+ components::UserAttributeBundleIter,
+ components::UserIDBundle,
+ components::UserIDBundleIter,
+ components::KeyIter,
+ components::ValidKeyIter,
+ key_amalgamation::KeyAmalgamation,
+ key_amalgamation::PrimaryKeyAmalgamation,
+ key_amalgamation::ValidKeyAmalgamation,
+ key_amalgamation::ValidPrimaryKeyAmalgamation,
+};
diff --git a/openpgp/src/cert/revoke.rs b/openpgp/src/cert/revoke.rs
index 523e9a24..341bdf5e 100644
--- a/openpgp/src/cert/revoke.rs
+++ b/openpgp/src/cert/revoke.rs
@@ -19,7 +19,7 @@ use crate::packet::{
UserAttribute,
UserID,
};
-use crate::cert::Cert;
+use crate::cert::prelude::*;
/// A `Cert` revocation builder.
///
@@ -40,7 +40,7 @@ use crate::cert::Cert;
/// # extern crate sequoia_openpgp as openpgp;
/// # use openpgp::Result;
/// use openpgp::types::{ReasonForRevocation, RevocationStatus, SignatureType};
-/// use openpgp::cert::{CipherSuite, CertBuilder, CertRevocationBuilder};
+/// use openpgp::cert::prelude::*;
/// use openpgp::crypto::KeyPair;
/// use openpgp::parse::Parse;
/// use sequoia_openpgp::policy::StandardPolicy;
@@ -273,8 +273,8 @@ impl Deref for SubkeyRevocationBuilder {
/// # Example
///
/// ```
-/// # use sequoia_openpgp::{*, packet::*, types::*, cert::*};
-/// use sequoia_openpgp::cert::components::ValidAmalgamation;
+/// # use sequoia_openpgp::{*, packet::*, types::*};
+/// use sequoia_openpgp::cert::prelude::*;
/// use sequoia_openpgp::policy::StandardPolicy;
///
/// # f().unwrap();
@@ -390,8 +390,8 @@ impl Deref for UserIDRevocationBuilder {
/// # Example
///
/// ```
-/// # use sequoia_openpgp::{*, packet::*, types::*, cert::*};
-/// use sequoia_openpgp::cert::components::ValidAmalgamation;
+/// # use sequoia_openpgp::{*, packet::*, types::*};
+/// use sequoia_openpgp::cert::prelude::*;
/// use sequoia_openpgp::policy::StandardPolicy;
///
/// # f().unwrap();