summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2020-12-04 20:06:17 +0100
committerAzul <azul@riseup.net>2020-12-08 10:35:58 +0100
commitb956d36cb50cac28aa9da0e373fb33c9a4c120af (patch)
treec20bb42230aed97494b6abe494bc8e22053f58a6
parent4a971af5abe70d41485df141a3d9fa97eaab5f1c (diff)
openpgp: Ensure public types are Send and Sync.
- See #627.
-rw-r--r--openpgp/src/armor.rs4
-rw-r--r--openpgp/src/cert.rs8
-rw-r--r--openpgp/src/cert/amalgamation.rs1
-rw-r--r--openpgp/src/cert/amalgamation/iter.rs1
-rw-r--r--openpgp/src/cert/builder.rs9
-rw-r--r--openpgp/src/cert/bundle.rs1
-rw-r--r--openpgp/src/cert/revoke.rs4
-rw-r--r--openpgp/src/crypto/aead.rs2
-rw-r--r--openpgp/src/crypto/asymmetric.rs1
-rw-r--r--openpgp/src/crypto/mem.rs1
-rw-r--r--openpgp/src/crypto/mod.rs2
-rw-r--r--openpgp/src/crypto/mpi.rs7
-rw-r--r--openpgp/src/crypto/s2k.rs1
-rw-r--r--openpgp/src/fingerprint.rs8
-rw-r--r--openpgp/src/fmt.rs2
-rw-r--r--openpgp/src/keyhandle.rs8
-rw-r--r--openpgp/src/keyid.rs7
-rw-r--r--openpgp/src/lib.rs6
-rw-r--r--openpgp/src/macros.rs42
-rw-r--r--openpgp/src/message/mod.rs8
-rw-r--r--openpgp/src/packet/aed.rs1
-rw-r--r--openpgp/src/packet/compressed_data.rs1
-rw-r--r--openpgp/src/packet/container.rs4
-rw-r--r--openpgp/src/packet/header/ctb.rs4
-rw-r--r--openpgp/src/packet/header/mod.rs2
-rw-r--r--openpgp/src/packet/key.rs20
-rw-r--r--openpgp/src/packet/literal.rs1
-rw-r--r--openpgp/src/packet/marker.rs1
-rw-r--r--openpgp/src/packet/mod.rs16
-rw-r--r--openpgp/src/packet/one_pass_sig.rs1
-rw-r--r--openpgp/src/packet/pkesk.rs2
-rw-r--r--openpgp/src/packet/seip.rs2
-rw-r--r--openpgp/src/packet/signature.rs3
-rw-r--r--openpgp/src/packet/signature/subpacket.rs7
-rw-r--r--openpgp/src/packet/tag.rs1
-rw-r--r--openpgp/src/packet/trust.rs2
-rw-r--r--openpgp/src/packet/unknown.rs2
-rw-r--r--openpgp/src/packet/user_attribute.rs4
-rw-r--r--openpgp/src/packet/userid.rs2
-rw-r--r--openpgp/src/packet_pile.rs8
-rw-r--r--openpgp/src/parse/map.rs2
-rw-r--r--openpgp/src/parse/packet_parser_builder.rs3
-rw-r--r--openpgp/src/policy.rs4
-rw-r--r--openpgp/src/serialize/stream.rs1
-rw-r--r--openpgp/src/types/compression_level.rs1
-rw-r--r--openpgp/src/types/features.rs1
-rw-r--r--openpgp/src/types/key_flags.rs1
-rw-r--r--openpgp/src/types/mod.rs3
-rw-r--r--openpgp/src/types/server_preferences.rs1
-rw-r--r--openpgp/src/types/timestamp.rs2
50 files changed, 170 insertions, 56 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs
index 9ff4c538..e901cc1b 100644
--- a/openpgp/src/armor.rs
+++ b/openpgp/src/armor.rs
@@ -72,6 +72,8 @@ pub enum Kind {
File,
}
+assert_send_and_sync!{Kind}
+
#[cfg(test)]
impl Arbitrary for Kind {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
@@ -172,6 +174,8 @@ pub struct Writer<W: Write> {
dirty: bool,
}
+assert_send_and_sync!{Writer<Vec<u8>>}
+
impl<W: Write> Writer<W> {
/// Constructs a new filter for the given type of data.
///
diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs
index 3876b8e1..287d1de9 100644
--- a/openpgp/src/cert.rs
+++ b/openpgp/src/cert.rs
@@ -729,6 +729,8 @@ pub struct Cert {
}
} // doc-hack, see above
+assert_send_and_sync!{Cert}
+
impl std::str::FromStr for Cert {
type Err = anyhow::Error;
@@ -4886,12 +4888,6 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g=
}
#[test]
- fn cert_is_send_and_sync() {
- fn f<T: Send + Sync>(_: T) {}
- f(Cert::from_bytes(crate::tests::key("testy-new.pgp")).unwrap());
- }
-
- #[test]
fn primary_userid() {
// 'really-revoked-userid' has two user ids. One of them is
// revoked and then restored. Neither of the user ids has the
diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs
index bfd634ef..9980784b 100644
--- a/openpgp/src/cert/amalgamation.rs
+++ b/openpgp/src/cert/amalgamation.rs
@@ -647,6 +647,7 @@ pub struct ComponentAmalgamation<'a, C> {
cert: &'a Cert,
bundle: &'a ComponentBundle<C>,
}
+assert_send_and_sync!{ComponentAmalgamation<'a, UserID>, 'a}
/// A User ID and its associated data.
///
diff --git a/openpgp/src/cert/amalgamation/iter.rs b/openpgp/src/cert/amalgamation/iter.rs
index b35bd48e..7af884d3 100644
--- a/openpgp/src/cert/amalgamation/iter.rs
+++ b/openpgp/src/cert/amalgamation/iter.rs
@@ -90,6 +90,7 @@ pub struct ComponentAmalgamationIter<'a, C> {
cert: &'a Cert,
iter: slice::Iter<'a, ComponentBundle<C>>,
}
+assert_send_and_sync!{ComponentAmalgamationIter<'a, UserID>, 'a}
/// An iterator over `UserIDAmalgamtion`s.
///
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs
index 660b9cfa..b84f02df 100644
--- a/openpgp/src/cert/builder.rs
+++ b/openpgp/src/cert/builder.rs
@@ -65,6 +65,7 @@ pub enum CipherSuite {
/// 4096 bit RSA with SHA512 and AES256
RSA4k,
}
+assert_send_and_sync!{CipherSuite}
impl Default for CipherSuite {
fn default() -> Self {
@@ -133,6 +134,7 @@ pub struct KeyBlueprint {
// CertBuilder::ciphersuite.
ciphersuite: Option<CipherSuite>,
}
+assert_send_and_sync!{KeyBlueprint}
/// Simplifies the generation of OpenPGP certificates.
///
@@ -173,6 +175,7 @@ pub struct CertBuilder<'a> {
revocation_keys: Option<Vec<RevocationKey>>,
phantom: PhantomData<&'a ()>,
}
+assert_send_and_sync!{CertBuilder<'a>, 'a}
impl CertBuilder<'_> {
/// Returns a new `CertBuilder`.
@@ -1432,10 +1435,4 @@ mod tests {
revokers.iter().collect::<HashSet<_>>());
Ok(())
}
-
- #[test]
- fn cert_builder_is_send_and_sync() {
- fn f<T: Send + Sync>(_: T) {}
- f(CertBuilder::new().generate().unwrap());
- }
}
diff --git a/openpgp/src/cert/bundle.rs b/openpgp/src/cert/bundle.rs
index 798a82c8..d8944777 100644
--- a/openpgp/src/cert/bundle.rs
+++ b/openpgp/src/cert/bundle.rs
@@ -125,6 +125,7 @@ pub struct ComponentBundle<C> {
// Third-party revocations (e.g., designated revokers).
pub(crate) other_revocations: Vec<Signature>,
}
+assert_send_and_sync!{ComponentBundle<UserID>}
/// A key (primary or subkey, public or private) and any associated
/// signatures.
diff --git a/openpgp/src/cert/revoke.rs b/openpgp/src/cert/revoke.rs
index a77e8885..24fdb55b 100644
--- a/openpgp/src/cert/revoke.rs
+++ b/openpgp/src/cert/revoke.rs
@@ -81,6 +81,7 @@ use crate::cert::prelude::*;
pub struct CertRevocationBuilder {
builder: signature::SignatureBuilder,
}
+assert_send_and_sync!{CertRevocationBuilder}
impl CertRevocationBuilder {
/// Returns a new `CertRevocationBuilder`.
@@ -318,6 +319,7 @@ impl Deref for CertRevocationBuilder {
pub struct SubkeyRevocationBuilder {
builder: signature::SignatureBuilder,
}
+assert_send_and_sync!{SubkeyRevocationBuilder}
impl SubkeyRevocationBuilder {
/// Returns a new `SubkeyRevocationBuilder`.
@@ -549,6 +551,7 @@ impl Deref for SubkeyRevocationBuilder {
pub struct UserIDRevocationBuilder {
builder: signature::SignatureBuilder,
}
+assert_send_and_sync!{UserIDRevocationBuilder}
impl UserIDRevocationBuilder {
/// Returns a new `UserIDRevocationBuilder`.
@@ -794,6 +797,7 @@ impl Deref for UserIDRevocationBuilder {
pub struct UserAttributeRevocationBuilder {
builder: signature::SignatureBuilder,
}
+assert_send_and_sync!{UserAttributeRevocationBuilder}
impl UserAttributeRevocationBuilder {
/// Returns a new `UserAttributeRevocationBuilder`.
diff --git a/openpgp/src/crypto/aead.rs b/openpgp/src/crypto/aead.rs
index ac658046..d98c8a53 100644
--- a/openpgp/src/crypto/aead.rs
+++ b/openpgp/src/crypto/aead.rs
@@ -116,6 +116,7 @@ pub struct Decryptor<'a> {
buffer: Vec<u8>,
}
+
impl<'a> Decryptor<'a> {
/// Instantiate a new AEAD decryptor.
///
@@ -543,6 +544,7 @@ pub struct Encryptor<W: io::Write> {
// A place to write encrypted data into.
scratch: Vec<u8>,
}
+assert_send_and_sync!{Encryptor<Vec<u8>>}
impl<W: io::Write> Encryptor<W> {
/// Instantiate a new AEAD encryptor.
diff --git a/openpgp/src/crypto/asymmetric.rs b/openpgp/src/crypto/asymmetric.rs
index 89941673..55b24d7d 100644
--- a/openpgp/src/crypto/asymmetric.rs
+++ b/openpgp/src/crypto/asymmetric.rs
@@ -137,6 +137,7 @@ pub struct KeyPair {
public: Key<key::PublicParts, key::UnspecifiedRole>,
secret: packet::key::Unencrypted,
}
+assert_send_and_sync!{KeyPair}
impl KeyPair {
/// Creates a new key pair.
diff --git a/openpgp/src/crypto/mem.rs b/openpgp/src/crypto/mem.rs
index f9979868..ea135a24 100644
--- a/openpgp/src/crypto/mem.rs
+++ b/openpgp/src/crypto/mem.rs
@@ -218,6 +218,7 @@ pub struct Encrypted {
ciphertext: Protected,
iv: Protected,
}
+assert_send_and_sync!{Encrypted}
impl PartialEq for Encrypted {
fn eq(&self, other: &Self) -> bool {
diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs
index 2177d327..5193fcca 100644
--- a/openpgp/src/crypto/mod.rs
+++ b/openpgp/src/crypto/mod.rs
@@ -48,6 +48,7 @@ pub(crate) mod symmetric;
/// [`From`]: https://doc.rust-lang.org/std/convert/trait.From.html
#[derive(Clone, PartialEq, Eq)]
pub struct SessionKey(mem::Protected);
+assert_send_and_sync!{SessionKey}
impl SessionKey {
/// Creates a new session key.
@@ -170,6 +171,7 @@ impl fmt::Debug for SessionKey {
/// ```
#[derive(Clone, PartialEq, Eq)]
pub struct Password(mem::Encrypted);
+assert_send_and_sync!{Password}
impl From<Vec<u8>> for Password {
fn from(v: Vec<u8>) -> Self {
diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs
index 9eac133b..541fd3b5 100644
--- a/openpgp/src/crypto/mpi.rs
+++ b/openpgp/src/crypto/mpi.rs
@@ -43,6 +43,7 @@ pub struct MPI {
/// Integer value as big-endian with leading zeros stripped.
value: Box<[u8]>,
}
+assert_send_and_sync!{MPI}
impl From<Vec<u8>> for MPI {
fn from(v: Vec<u8>) -> Self {
@@ -296,6 +297,7 @@ pub struct ProtectedMPI {
/// Integer value as big-endian.
value: Protected,
}
+assert_send_and_sync!{ProtectedMPI}
impl From<Vec<u8>> for ProtectedMPI {
fn from(m: Vec<u8>) -> Self {
@@ -504,6 +506,7 @@ pub enum PublicKey {
rest: Box<[u8]>,
},
}
+assert_send_and_sync!{PublicKey}
impl PublicKey {
/// Returns t