Merge pull request #866 from sfackler/more-sync
Impl Sync and Send for various types
This commit is contained in:
commit
c3b6e87244
|
|
@ -11,6 +11,9 @@ use pkey::{HasPrivate, HasPublic, PKeyRef};
|
||||||
/// A type used to derive a shared secret between two keys.
|
/// A type used to derive a shared secret between two keys.
|
||||||
pub struct Deriver<'a>(*mut ffi::EVP_PKEY_CTX, PhantomData<&'a ()>);
|
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> {
|
impl<'a> Deriver<'a> {
|
||||||
/// Creates a new `Deriver` using the provided private key.
|
/// Creates a new `Deriver` using the provided private key.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,9 @@ impl MessageDigest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl Sync for MessageDigest {}
|
||||||
|
unsafe impl Send for MessageDigest {}
|
||||||
|
|
||||||
#[derive(PartialEq, Copy, Clone)]
|
#[derive(PartialEq, Copy, Clone)]
|
||||||
enum State {
|
enum State {
|
||||||
Reset,
|
Reset,
|
||||||
|
|
@ -99,6 +102,9 @@ pub struct Hasher {
|
||||||
state: State,
|
state: State,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl Sync for Hasher {}
|
||||||
|
unsafe impl Send for Hasher {}
|
||||||
|
|
||||||
impl Hasher {
|
impl Hasher {
|
||||||
/// Creates a new `Hasher` with the specified hash type.
|
/// Creates a new `Hasher` with the specified hash type.
|
||||||
pub fn new(ty: MessageDigest) -> Result<Hasher, ErrorStack> {
|
pub fn new(ty: MessageDigest) -> Result<Hasher, ErrorStack> {
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,9 @@ pub struct Signer<'a> {
|
||||||
_p: PhantomData<&'a ()>,
|
_p: PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl<'a> Sync for Signer<'a> {}
|
||||||
|
unsafe impl<'a> Send for Signer<'a> {}
|
||||||
|
|
||||||
impl<'a> Drop for Signer<'a> {
|
impl<'a> Drop for Signer<'a> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// pkey_ctx is owned by the md_ctx, so no need to explicitly free it.
|
// 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 ()>,
|
pkey_pd: PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl<'a> Sync for Verifier<'a> {}
|
||||||
|
unsafe impl<'a> Send for Verifier<'a> {}
|
||||||
|
|
||||||
impl<'a> Drop for Verifier<'a> {
|
impl<'a> Drop for Verifier<'a> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// pkey_ctx is owned by the md_ctx, so no need to explicitly free it.
|
// pkey_ctx is owned by the md_ctx, so no need to explicitly free it.
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,9 @@ impl Cipher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl Sync for Cipher {}
|
||||||
|
unsafe impl Send for Cipher {}
|
||||||
|
|
||||||
/// Represents a symmetric cipher context.
|
/// Represents a symmetric cipher context.
|
||||||
///
|
///
|
||||||
/// Padding is enabled by default.
|
/// Padding is enabled by default.
|
||||||
|
|
@ -288,6 +291,9 @@ pub struct Crypter {
|
||||||
block_size: usize,
|
block_size: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl Sync for Crypter {}
|
||||||
|
unsafe impl Send for Crypter {}
|
||||||
|
|
||||||
impl Crypter {
|
impl Crypter {
|
||||||
/// Creates a new `Crypter`. The initialisation vector, `iv`, is not necesarry for certain
|
/// Creates a new `Crypter`. The initialisation vector, `iv`, is not necesarry for certain
|
||||||
/// types of `Cipher`.
|
/// types of `Cipher`.
|
||||||
|
|
@ -963,7 +969,6 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_des_ede3_cbc() {
|
fn test_des_ede3_cbc() {
|
||||||
|
|
||||||
let pt = "54686973206973206120746573742e";
|
let pt = "54686973206973206120746573742e";
|
||||||
let ct = "6f2867cfefda048a4046ef7e556c7132";
|
let ct = "6f2867cfefda048a4046ef7e556c7132";
|
||||||
let key = "7cb66337f3d3c0fe7cb66337f3d3c0fe7cb66337f3d3c0fe";
|
let key = "7cb66337f3d3c0fe7cb66337f3d3c0fe7cb66337f3d3c0fe";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue