aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2018-03-09 22:14:50 -0800
committerSteven Fackler <[email protected]>2018-03-09 22:14:50 -0800
commit245f5f3a11f9ef7a18131b0341d329089a29b3e1 (patch)
treefb45c306e04fa677d95e00614eb0a8917f53cfa8 /openssl/src
parentRemove the x509 module-level example (diff)
downloadrust-openssl-245f5f3a11f9ef7a18131b0341d329089a29b3e1.tar.xz
rust-openssl-245f5f3a11f9ef7a18131b0341d329089a29b3e1.zip
Impl Sync and Send for various types
Closes #865
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/derive.rs3
-rw-r--r--openssl/src/hash.rs6
-rw-r--r--openssl/src/sign.rs6
-rw-r--r--openssl/src/symm.rs7
4 files changed, 21 insertions, 1 deletions
diff --git a/openssl/src/derive.rs b/openssl/src/derive.rs
index fb7bbf14..30d7dc25 100644
--- a/openssl/src/derive.rs
+++ b/openssl/src/derive.rs
@@ -11,6 +11,9 @@ use pkey::{HasPrivate, HasPublic, PKeyRef};
/// A type used to derive a shared secret between two keys.
pub struct Deriver<'a>(*mut ffi::EVP_PKEY_CTX, PhantomData<&'a ()>);
+unsafe impl<'a> Sync for Deriver<'a> {}
+unsafe impl<'a> Send for Deriver<'a> {}
+
impl<'a> Deriver<'a> {
/// Creates a new `Deriver` using the provided private key.
///
diff --git a/openssl/src/hash.rs b/openssl/src/hash.rs
index 103a7ae3..c6d4c862 100644
--- a/openssl/src/hash.rs
+++ b/openssl/src/hash.rs
@@ -49,6 +49,9 @@ impl MessageDigest {
}
}
+unsafe impl Sync for MessageDigest {}
+unsafe impl Send for MessageDigest {}
+
#[derive(PartialEq, Copy, Clone)]
enum State {
Reset,
@@ -99,6 +102,9 @@ pub struct Hasher {
state: State,
}
+unsafe impl Sync for Hasher {}
+unsafe impl Send for Hasher {}
+
impl Hasher {
/// Creates a new `Hasher` with the specified hash type.
pub fn new(ty: MessageDigest) -> Result<Hasher, ErrorStack> {
diff --git a/openssl/src/sign.rs b/openssl/src/sign.rs
index a61d883b..8911a69a 100644
--- a/openssl/src/sign.rs
+++ b/openssl/src/sign.rs
@@ -85,6 +85,9 @@ pub struct Signer<'a> {
_p: PhantomData<&'a ()>,
}
+unsafe impl<'a> Sync for Signer<'a> {}
+unsafe impl<'a> Send for Signer<'a> {}
+
impl<'a> Drop for Signer<'a> {
fn drop(&mut self) {
// pkey_ctx is owned by the md_ctx, so no need to explicitly free it.
@@ -244,6 +247,9 @@ pub struct Verifier<'a> {
pkey_pd: PhantomData<&'a ()>,
}
+unsafe impl<'a> Sync for Verifier<'a> {}
+unsafe impl<'a> Send for Verifier<'a> {}
+
impl<'a> Drop for Verifier<'a> {
fn drop(&mut self) {
// pkey_ctx is owned by the md_ctx, so no need to explicitly free it.
diff --git a/openssl/src/symm.rs b/openssl/src/symm.rs
index 630f4ab6..1cb2ef81 100644
--- a/openssl/src/symm.rs
+++ b/openssl/src/symm.rs
@@ -223,6 +223,9 @@ impl Cipher {
}
}
+unsafe impl Sync for Cipher {}
+unsafe impl Send for Cipher {}
+
/// Represents a symmetric cipher context.
///
/// Padding is enabled by default.
@@ -288,6 +291,9 @@ pub struct Crypter {
block_size: usize,
}
+unsafe impl Sync for Crypter {}
+unsafe impl Send for Crypter {}
+
impl Crypter {
/// Creates a new `Crypter`. The initialisation vector, `iv`, is not necesarry for certain
/// types of `Cipher`.
@@ -963,7 +969,6 @@ mod tests {
#[test]
fn test_des_ede3_cbc() {
-
let pt = "54686973206973206120746573742e";
let ct = "6f2867cfefda048a4046ef7e556c7132";
let key = "7cb66337f3d3c0fe7cb66337f3d3c0fe7cb66337f3d3c0fe";