summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2020-12-04 20:06:17 +0100
committerAzul <azul@riseup.net>2020-12-05 14:44:17 +0100
commit405e43ee06d69e3dd19f6f5116ff0c46f3076de6 (patch)
tree6f17555b8176067baf5c5fb0407c172cf8399257
parent6de3f7f02ef14d7d84e6d0a7aff6aaee12444392 (diff)
openpgp: Ensure public types are Send and Sync.azul/sendable-trait
- 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 bc274021..7492cf04 100644
--- a/openpgp/src/cert.rs
+++ b/openpgp/src/cert.rs
@@ -726,6 +726,8 @@ pub struct Cert {
}
} // doc-hack, see above
+assert_send_and_sync!{Cert}
+
impl std::str::FromStr for Cert {
type Err = anyhow::Error;
@@ -4883,12 +4885,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 1934f3be..39440408 100644
--- a/openpgp/src/crypto/asymmetric.rs
+++ b/openpgp/src/crypto/asymmetric.rs
@@ -126,6 +126,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 96f80483..330ca0b5 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 8f9cfb2a..2c381f71 100644
--- a/openpgp/src/crypto/mpi.rs
+++ b/openpgp/src/crypto/mpi.rs
@@ -42,6 +42,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 {
@@ -295,6 +296,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 {
@@ -503,6 +505,7 @@ pub enum PublicKey {
rest: Box<[u8]>,
},
}
+assert_send_and_sync!{PublicKey}
impl PublicKey {
/// Returns the length of the public key in bits.
@@ -662,6 +665,7 @@ pub enum SecretKeyMaterial {
rest: Protected,
},
}
+assert_send_and_sync!{SecretKeyMaterial}
impl fmt::Debug for SecretKeyMaterial {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -861,6 +865,7 @@ pub enum SecretKeyChecksum {
/// Sum of the decrypted secret key octets modulo 65536.
Sum16,
}
+assert_send_and_sync!{SecretKeyChecksum}
impl Default for SecretKeyChecksum {
fn default() -> Self {
@@ -910,6 +915,7 @@ pub enum Ciphertext {
rest: Box<[u8]>,
},
}
+assert_send_and_sync!{Ciphertext}
impl Ciphertext {
/// Returns, if known, the public-key algorithm for this
@@ -1019,6 +1025,7 @@ pub enum Signature {
rest: Box<[u8]>,
},
}
+assert_send_and_sync!{Signature}
impl Hash for Signature {
fn hash(&self, hash: &mut hash::Context) {
diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs
index ecc6313e..a282c402 100644
--- a/openpgp/src/crypto/s2k.rs
+++ b/openpgp/src/crypto/s2k.rs
@@ -113,6 +113,7 @@ pub enum S2K {
parameters: Option<Box<[u8]>>,
},
}
+assert_send_and_sync!{S2K}
impl Default for S2K {
fn default() -> Self {
diff --git a/openpgp/src/fingerprint.rs b/openpgp/src/fingerprint.rs
index 3af4a70e..bd6d0ffe 100644
--- a/openpgp/src/fingerprint.rs
+++ b/openpgp/src/fingerprint.rs
@@ -53,6 +53,7 @@ pub enum Fingerprint {
/// V3 fingerprint (deprecated) or otherwise wrong-length data.
Invalid(Box<[u8]>),
}
+assert_send_and_sync!{Fingerprint}
impl fmt::Display for Fingerprint {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -331,11 +332,4 @@ mod tests {
assert_eq!(format!("{:X}", fp), "0123456789ABCDEF0123456789ABCDEF01234567");
assert_eq!(format!("{:x}", fp), "0123456789abcdef0123456789abcdef01234567");
}
-
- #[test]
- fn fingerprint_is_send_and_sync() {
- fn f<T: Send + Sync>(_: T) {}
- f("0123 4567 89AB CDEF 0123 4567 89AB CDEF 0123 4567"
- .parse::<Fingerprint>().unwrap());
- }
}
diff --git a/openpgp/src/fmt.rs b/openpgp/src/fmt.rs
index d36217d2..c06c6faf 100644
--- a/openpgp/src/fmt.rs
+++ b/openpgp/src/fmt.rs
@@ -61,6 +61,8 @@ pub mod hex {
offset: usize,
}
+ assert_send_and_sync!{Dumper<Vec<u8>>}
+
impl<W: io::Write> Dumper<W> {
/// Creates a new dumper.
///
diff --git a/openpgp/src/keyhandle.rs b/openpgp/src/keyhandle.rs
index cfa78f3a..2eb8bb94 100644
--- a/openpgp/src/keyhandle.rs
+++ b/openpgp/src/keyhandle.rs
@@ -79,6 +79,