diff --git a/openssl/src/cipher.rs b/openssl/src/cipher.rs index f81895e51350f2f887bcb6774a61167c7dfed113..270f653c97ce6ee76f96b542c5ec9ead426500a2 100644 --- a/openssl/src/cipher.rs +++ b/openssl/src/cipher.rs @@ -146,7 +146,7 @@ impl Cipher { let ptr = cvt_p(ffi::EVP_CIPHER_fetch( ctx.map_or(ptr::null_mut(), ForeignTypeRef::as_ptr), algorithm.as_ptr(), - properties.map_or(ptr::null_mut(), |s| s.as_ptr()), + properties.as_ref().map_or(ptr::null_mut(), |s| s.as_ptr()), ))?; Ok(Cipher::from_ptr(ptr)) @@ -534,3 +534,15 @@ impl CipherRef { unsafe { EVP_CIPHER_block_size(self.as_ptr()) as usize } } } + +#[cfg(test)] +mod test { + #[cfg(ossl300)] + use super::Cipher; + + #[test] + #[cfg(ossl300)] + fn test_cipher_fetch_properties() { + assert!(Cipher::fetch(None, "AES-128-GCM", Some("provider=gibberish")).is_err()); + } +} \ No newline at end of file diff --git a/openssl/src/lib.rs b/openssl/src/lib.rs index 28b73f31ffeb5290daad0512926a79c8c675218a..d4120e9844767c47cb575a5e786c2aca035230df 100644 --- a/openssl/src/lib.rs +++ b/openssl/src/lib.rs @@ -56,12 +56,12 @@ //! override the automatic detection logic. //! //! * `OPENSSL_DIR` - If specified, the directory of an OpenSSL installation. The directory should contain `lib` and -//! `include` subdirectories containing the libraries and headers respectively. +//! `include` subdirectories containing the libraries and headers respectively. //! * `OPENSSL_LIB_DIR` and `OPENSSL_INCLUDE_DIR` - If specified, the directories containing the OpenSSL libraries and -//! headers respectively. This can be used if the OpenSSL installation is split in a nonstandard directory layout. +//! headers respectively. This can be used if the OpenSSL installation is split in a nonstandard directory layout. //! * `OPENSSL_STATIC` - If set, the crate will statically link to OpenSSL rather than dynamically link. //! * `OPENSSL_LIBS` - If set, a `:`-separated list of library names to link to (e.g. `ssl:crypto`). This can be used -//! if nonstandard library names were used for whatever reason. +//! if nonstandard library names were used for whatever reason. //! * `OPENSSL_NO_VENDOR` - If set, always find OpenSSL in the system, even if the `vendored` feature is enabled. //! //! Additionally, these variables can be prefixed with the upper-cased target architecture (e.g. diff --git a/openssl/src/md.rs b/openssl/src/md.rs index 4ade8e870da2348d5c877db073d331f64c39e5ea..a08b35a09b85f71fae3ff529f1841f3c62001bd3 100644 --- a/openssl/src/md.rs +++ b/openssl/src/md.rs @@ -107,7 +107,7 @@ impl Md { let ptr = cvt_p(ffi::EVP_MD_fetch( ctx.map_or(ptr::null_mut(), ForeignTypeRef::as_ptr), algorithm.as_ptr(), - properties.map_or(ptr::null_mut(), |s| s.as_ptr()), + properties.as_ref().map_or(ptr::null_mut(), |s| s.as_ptr()), ))?; Ok(Md::from_ptr(ptr)) @@ -233,3 +233,15 @@ impl MdRef { unsafe { Nid::from_raw(ffi::EVP_MD_type(self.as_ptr())) } } } + +#[cfg(test)] +mod test { + #[cfg(ossl300)] + use super::Md; + + #[test] + #[cfg(ossl300)] + fn test_md_fetch_properties() { + assert!(Md::fetch(None, "SHA-256", Some("provider=gibberish")).is_err()); + } +} \ No newline at end of file