diff options
author | Azul <azul@riseup.net> | 2020-12-04 20:06:17 +0100 |
---|---|---|
committer | Azul <azul@riseup.net> | 2020-12-08 10:35:58 +0100 |
commit | b956d36cb50cac28aa9da0e373fb33c9a4c120af (patch) | |
tree | c20bb42230aed97494b6abe494bc8e22053f58a6 /openpgp/src/crypto | |
parent | 4a971af5abe70d41485df141a3d9fa97eaab5f1c (diff) |
openpgp: Ensure public types are Send and Sync.
- See #627.
Diffstat (limited to 'openpgp/src/crypto')
-rw-r--r-- | openpgp/src/crypto/aead.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/asymmetric.rs | 1 | ||||
-rw-r--r-- | openpgp/src/crypto/mem.rs | 1 | ||||
-rw-r--r-- | openpgp/src/crypto/mod.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/mpi.rs | 7 | ||||
-rw-r--r-- | openpgp/src/crypto/s2k.rs | 1 |
6 files changed, 14 insertions, 0 deletions
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 the length of the public key in bits. @@ -664,6 +667,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 { @@ -864,6 +868,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 { @@ -913,6 +918,7 @@ pub enum Ciphertext { rest: Box<[u8]>, }, } +assert_send_and_sync!{Ciphertext} impl Ciphertext { /// Returns, if known, the public-key algorithm for this @@ -1023,6 +1029,7 @@ pub enum Signature { rest: Box<[u8]>, }, } +assert_send_and_sync!{Signature} impl Hash for Signature { fn hash(&self, mut hash: &mut dyn hash::Digest) { diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs index 93430810..18472554 100644 --- a/openpgp/src/crypto/s2k.rs +++ b/openpgp/src/crypto/s2k.rs @@ -114,6 +114,7 @@ pub enum S2K { parameters: Option<Box<[u8]>>, }, } +assert_send_and_sync!{S2K} impl Default for S2K { fn default() -> Self { |