summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-03-21 12:11:55 +0100
committerJustus Winter <justus@sequoia-pgp.org>2018-03-23 11:33:43 +0100
commit560faea8ee7ea5e0535f642a32ff36a2bb5279a1 (patch)
treea9982dd5a4dd44b0bd52ac427722192164e9a403
parentdc0043e28aa140bc2f6509fad04652e9e71cba8a (diff)
openpgp: Move the TPK type definition to openpgp proper.
- We define all types in the root of the openpgp crate, and their implementations in separate modules. This makes using these types much simpler, yet keeps the root from getting too crowded. - Also fix all users accordingly.
-rw-r--r--examples/guide-exploring-openpgp.rs2
-rw-r--r--examples/guide-the-keystore.rs2
-rw-r--r--ffi/src/net.rs2
-rw-r--r--ffi/src/openpgp.rs2
-rw-r--r--ffi/src/store.rs2
-rw-r--r--net/src/async.rs2
-rw-r--r--net/src/lib.rs2
-rw-r--r--net/tests/hkp.rs2
-rw-r--r--openpgp/src/hash.rs2
-rw-r--r--openpgp/src/lib.rs15
-rw-r--r--openpgp/src/tpk.rs17
-rw-r--r--store/src/backend/mod.rs3
-rw-r--r--store/src/lib.rs10
-rw-r--r--tool/src/main.rs2
14 files changed, 32 insertions, 33 deletions
diff --git a/examples/guide-exploring-openpgp.rs b/examples/guide-exploring-openpgp.rs
index af4b7a7d..bc05a7e1 100644
--- a/examples/guide-exploring-openpgp.rs
+++ b/examples/guide-exploring-openpgp.rs
@@ -49,7 +49,7 @@ fn main() {
println!();
// Parse into TPK.
- let tpk = openpgp::tpk::TPK::from_message(message).unwrap();
+ let tpk = openpgp::TPK::from_message(message).unwrap();
println!("Fingerprint: {}", tpk.fingerprint());
// List userids.
diff --git a/examples/guide-the-keystore.rs b/examples/guide-the-keystore.rs
index 0baa8a05..91f049f0 100644
--- a/examples/guide-the-keystore.rs
+++ b/examples/guide-the-keystore.rs
@@ -43,7 +43,7 @@ fn main() {
let ctx = core::Context::new("org.sequoia-pgp.guide").unwrap();
// Parse TPK.
- let tpk = openpgp::tpk::TPK::from_reader(&mut reader).unwrap();
+ let tpk = openpgp::TPK::from_reader(&mut reader).unwrap();
// Open a store.
let store = store::Store::open(&ctx, "default").unwrap();
diff --git a/ffi/src/net.rs b/ffi/src/net.rs
index 8ae70608..49440545 100644
--- a/ffi/src/net.rs
+++ b/ffi/src/net.rs
@@ -33,7 +33,7 @@ use std::slice;
extern crate openpgp;
-use self::openpgp::tpk::TPK;
+use self::openpgp::TPK;
use self::openpgp::KeyID;
use sequoia_net::KeyServer;
diff --git a/ffi/src/openpgp.rs b/ffi/src/openpgp.rs
index 81432193..f21bb7a7 100644
--- a/ffi/src/openpgp.rs
+++ b/ffi/src/openpgp.rs
@@ -9,7 +9,7 @@ use libc::{uint8_t, uint64_t, c_char, c_int, size_t};
extern crate openpgp;
-use self::openpgp::tpk::TPK;
+use self::openpgp::TPK;
use self::openpgp::{armor, Fingerprint, KeyID, Message};
use super::build_hasher;
diff --git a/ffi/src/store.rs b/ffi/src/store.rs
index 5e62660b..d52af90e 100644
--- a/ffi/src/store.rs
+++ b/ffi/src/store.rs
@@ -29,7 +29,7 @@ use std::ptr;
extern crate openpgp;
-use self::openpgp::tpk::TPK;
+use self::openpgp::TPK;
use self::openpgp::Fingerprint;
use sequoia_store::{
self, Store, StoreIter, Binding, BindingIter, Key, KeyIter, LogIter,
diff --git a/net/src/async.rs b/net/src/async.rs
index 27b5b44b..9ee962e2 100644
--- a/net/src/async.rs
+++ b/net/src/async.rs
@@ -16,7 +16,7 @@ use std::io::Cursor;
use tokio_core::reactor::Handle;
use url::Url;
-use openpgp::tpk::TPK;
+use openpgp::TPK;
use openpgp::{KeyID, armor};
use sequoia_core::{Context, NetworkPolicy};
diff --git a/net/src/lib.rs b/net/src/lib.rs
index 94baaa05..d01aa93d 100644
--- a/net/src/lib.rs
+++ b/net/src/lib.rs
@@ -56,7 +56,7 @@ use tokio_core::reactor::Core;
use url::Url;
use openpgp::KeyID;
-use openpgp::tpk::TPK;
+use openpgp::TPK;
use sequoia_core::Context;
pub mod async;
diff --git a/net/tests/hkp.rs b/net/tests/hkp.rs
index a3ee9c89..d3da0f93 100644
--- a/net/tests/hkp.rs
+++ b/net/tests/hkp.rs
@@ -21,7 +21,7 @@ extern crate sequoia_core;
extern crate sequoia_net;
use openpgp::armor::{Reader, Kind};
-use openpgp::tpk::TPK;
+use openpgp::TPK;
use openpgp::{Fingerprint, KeyID};
use sequoia_core::{Context, NetworkPolicy};
use sequoia_net::KeyServer;
diff --git a/openpgp/src/hash.rs b/openpgp/src/hash.rs
index a7942b84..01a25a40 100644
--- a/openpgp/src/hash.rs
+++ b/openpgp/src/hash.rs
@@ -198,7 +198,7 @@ impl Signature {
#[cfg(test)]
mod test {
- use tpk::TPK;
+ use TPK;
macro_rules! bytes {
( $x:expr ) => { include_bytes!(concat!("../tests/data/keys/", $x)) };
diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs
index 795031b9..3edef59b 100644
--- a/openpgp/src/lib.rs
+++ b/openpgp/src/lib.rs
@@ -891,6 +891,21 @@ pub struct Message {
// containers.
top_level: Container,
}
+
+/// A transferable public key (TPK).
+///
+/// A TPK (see [RFC 4880, section 11.1]) can be used to verify
+/// signatures and encrypt data. It can be stored in a keystore and
+/// uploaded to keyservers.
+///
+/// [RFC 4880, section 11.1]: https://tools.ietf.org/html/rfc4880#section-11.1
+#[derive(Debug, Clone, PartialEq)]
+pub struct TPK {
+ primary: Key,
+ userids: Vec<tpk::UserIDBinding>,
+ user_attributes: Vec<tpk::UserAttributeBinding>,
+ subkeys: Vec<tpk::SubkeyBinding>,
+}
/// A `PacketIter` iterates over the *contents* of a packet in
/// depth-first order. It starts by returning the current packet.
diff --git a/openpgp/src/tpk.rs b/openpgp/src/tpk.rs
index 47054c9b..37846b5e 100644
--- a/openpgp/src/tpk.rs
+++ b/openpgp/src/tpk.rs
@@ -7,25 +7,10 @@ use std::path::Path;
use std::fs::File;
use std::slice;
-use super::{Packet, Message, Signature, Key, UserID, UserAttribute,
+use super::{TPK, Packet, Message, Signature, Key, UserID, UserAttribute,
Fingerprint, Tag};
use super::parse::PacketParser;
-/// A transferable public key (TPK).
-///
-/// A TPK (see [RFC 4880, section 11.1]) can be used to verify
-/// signatures and encrypt data. It can be stored in a keystore and
-/// uploaded to keyservers.
-///
-/// [RFC 4880, section 11.1]: https://tools.ietf.org/html/rfc4880#section-11.1
-#[derive(Debug, Clone, PartialEq)]
-pub struct TPK {
- primary: Key,
- userids: Vec<UserIDBinding>,
- user_attributes: Vec<UserAttributeBinding>,
- subkeys: Vec<SubkeyBinding>,
-}
-
#[derive(Debug, Clone, PartialEq)]
pub struct SubkeyBinding {
subkey: Key,
diff --git a/store/src/backend/mod.rs b/store/src/backend/mod.rs
index bb03f33b..344697e6 100644
--- a/store/src/backend/mod.rs
+++ b/store/src/backend/mod.rs
@@ -21,8 +21,7 @@ use tokio_core::reactor::{Handle, Timeout};
use tokio_core;
use tokio_io::io::ReadHalf;
-use openpgp::{self, Fingerprint};
-use openpgp::tpk::{self, TPK};
+use openpgp::{self, tpk, TPK, Fingerprint};
use sequoia_core as core;
use sequoia_net as net;
use sequoia_net::ipc;
diff --git a/store/src/lib.rs b/store/src/lib.rs
index f617aa83..406c1c78 100644
--- a/store/src/lib.rs
+++ b/store/src/lib.rs
@@ -77,7 +77,7 @@ extern crate sequoia_core;
extern crate sequoia_net;
use openpgp::Fingerprint;
-use openpgp::tpk::TPK;
+use openpgp::TPK;
use sequoia_core as core;
use sequoia_core::Context;
use sequoia_net::ipc;
@@ -225,7 +225,7 @@ impl Store {
/// # extern crate openpgp;
/// # extern crate sequoia_core;
/// # extern crate sequoia_store;
- /// # use openpgp::tpk::TPK;
+ /// # use openpgp::TPK;
/// # use sequoia_core::{Context, NetworkPolicy, IPCPolicy};
/// # use sequoia_store::{Store, Result};
/// # fn main() { f().unwrap(); }
@@ -450,7 +450,7 @@ impl Binding {
/// # extern crate openpgp;
/// # #[macro_use] extern crate sequoia_core;
/// # extern crate sequoia_store;
- /// # use openpgp::tpk::TPK;
+ /// # use openpgp::TPK;
/// # use sequoia_core::{Context, NetworkPolicy, IPCPolicy};
/// # use sequoia_store::{Store, Result, Error};
/// # fn main() { f().unwrap(); }
@@ -508,7 +508,7 @@ impl Binding {
/// # extern crate openpgp;
/// # #[macro_use] extern crate sequoia_core;
/// # extern crate sequoia_store;
- /// # use openpgp::tpk::TPK;
+ /// # use openpgp::TPK;
/// # use sequoia_core::{Context, NetworkPolicy, IPCPolicy};
/// # use sequoia_store::{Store, Result, Error};
/// # fn main() { f().unwrap(); }
@@ -647,7 +647,7 @@ impl Key {
/// # #[macro_use] extern crate sequoia_core;
/// # extern crate sequoia_store;
/// # use openpgp::Fingerprint;
- /// # use openpgp::tpk::TPK;
+ /// # use openpgp::TPK;
/// # use sequoia_core::{Context, NetworkPolicy, IPCPolicy};
/// # use sequoia_store::{Store, Result, Error};
/// # fn main() { f().unwrap(); }
diff --git a/tool/src/main.rs b/tool/src/main.rs
index c96178fd..01bbddb4 100644
--- a/tool/src/main.rs
+++ b/tool/src/main.rs
@@ -21,7 +21,7 @@ extern crate sequoia_net;
extern crate sequoia_store;
use openpgp::{armor, Fingerprint};
-use openpgp::tpk::TPK;
+use openpgp::TPK;
use sequoia_core::{Context, NetworkPolicy};
use sequoia_net::KeyServer;
use sequoia_store::{Store, LogIter};