From 63cf8e1f7c9eb8c1f3e107d2ba7dc41c9e4abd16 Mon Sep 17 00:00:00 2001 From: Edoardo Morandi Date: Sat, 5 Dec 2020 15:31:29 +0100 Subject: [PATCH] Add minimal openssl/libressl version for OAEP --- openssl-sys/src/rsa.rs | 2 ++ openssl/src/encrypt.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/openssl-sys/src/rsa.rs b/openssl-sys/src/rsa.rs index b1f8fe7054..dd7cab959b 100644 --- a/openssl-sys/src/rsa.rs +++ b/openssl-sys/src/rsa.rs @@ -49,6 +49,7 @@ pub unsafe fn EVP_PKEY_CTX_set_rsa_mgf1_md(ctx: *mut EVP_PKEY_CTX, md: *mut EVP_ ) } +#[cfg(any(ossl102, libressl310))] pub unsafe fn EVP_PKEY_CTX_set_rsa_oaep_md(ctx: *mut EVP_PKEY_CTX, md: *mut EVP_MD) -> c_int { EVP_PKEY_CTX_ctrl( ctx, @@ -67,6 +68,7 @@ pub const EVP_PKEY_CTRL_RSA_MGF1_MD: c_int = EVP_PKEY_ALG_CTRL + 5; pub const EVP_PKEY_CTRL_GET_RSA_PADDING: c_int = EVP_PKEY_ALG_CTRL + 6; +#[cfg(any(ossl102, libressl310))] pub const EVP_PKEY_CTRL_RSA_OAEP_MD: c_int = EVP_PKEY_ALG_CTRL + 9; pub const RSA_PKCS1_PADDING: c_int = 1; diff --git a/openssl/src/encrypt.rs b/openssl/src/encrypt.rs index aec2270839..1ec8bdc097 100644 --- a/openssl/src/encrypt.rs +++ b/openssl/src/encrypt.rs @@ -104,6 +104,7 @@ impl<'a> Encrypter<'a> { /// This corresponds to [`EVP_PKEY_CTX_set_rsa_oaep_md`]. /// /// [`EVP_PKEY_CTX_set_rsa_oaep_md`]: https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_CTX_set_rsa_oaep_md.html + #[cfg(any(ossl102, libressl310))] pub fn set_rsa_oaep_md(&mut self, md: MessageDigest) -> Result<(), ErrorStack> { unsafe { cvt(ffi::EVP_PKEY_CTX_set_rsa_oaep_md( @@ -299,6 +300,7 @@ mod test { } #[test] + #[cfg(any(ossl102, libressl310))] fn rsa_encrypt_decrypt_with_sha256() { let key = include_bytes!("../test/rsa.pem"); let private_key = Rsa::private_key_from_pem(key).unwrap();