From d207897458f8fbd0b2ff6d879721b2f787a5d72b Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 30 Dec 2017 21:46:17 -0800 Subject: Parameterize keys over what they contain Closes #790 --- openssl/src/cms.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'openssl/src/cms.rs') diff --git a/openssl/src/cms.rs b/openssl/src/cms.rs index 160d2daf..8c60455c 100644 --- a/openssl/src/cms.rs +++ b/openssl/src/cms.rs @@ -8,15 +8,12 @@ use ffi; use foreign_types::{ForeignType, ForeignTypeRef}; use std::ptr; -use error::ErrorStack; +use {cvt, cvt_p}; use bio::{MemBio, MemBioSlice}; - +use error::ErrorStack; +use pkey::{HasPrivate, PKeyRef}; use x509::X509; -use pkey::PKeyRef; - -use cvt; -use cvt_p; foreign_type_and_impl_send_sync! { type CType = ffi::CMS_ContentInfo; @@ -44,7 +41,10 @@ impl CmsContentInfoRef { /// OpenSSL documentation at [`CMS_decrypt`] /// /// [`CMS_decrypt`]: https://www.openssl.org/docs/man1.1.0/crypto/CMS_decrypt.html - pub fn decrypt(&self, pkey: &PKeyRef, cert: &X509) -> Result, ErrorStack> { + pub fn decrypt(&self, pkey: &PKeyRef, cert: &X509) -> Result, ErrorStack> + where + T: HasPrivate, + { unsafe { let pkey = pkey.as_ptr(); let cert = cert.as_ptr(); @@ -63,7 +63,6 @@ impl CmsContentInfoRef { Ok(out.get_buf().to_owned()) } } - } impl CmsContentInfo { @@ -76,10 +75,7 @@ impl CmsContentInfo { unsafe { let bio = MemBioSlice::new(smime)?; - let cms = cvt_p(ffi::SMIME_read_CMS( - bio.as_ptr(), - ptr::null_mut(), - ))?; + let cms = cvt_p(ffi::SMIME_read_CMS(bio.as_ptr(), ptr::null_mut()))?; Ok(CmsContentInfo::from_ptr(cms)) } -- cgit v1.2.3