diff --git a/openssl-sys/src/handwritten/cms.rs b/openssl-sys/src/handwritten/cms.rs index a13ea423c4..7f453ee327 100644 --- a/openssl-sys/src/handwritten/cms.rs +++ b/openssl-sys/src/handwritten/cms.rs @@ -62,4 +62,17 @@ extern "C" { out: *mut BIO, flags: c_uint, ) -> c_int; + +} + +cfg_if! { + if #[cfg(ossl111)] { + extern "C" { + pub fn CMS_get0_type(cms: *const CMS_ContentInfo) -> *const ASN1_OBJECT; + } + } else { + extern "C" { + pub fn CMS_get0_type(cms: *mut CMS_ContentInfo) -> *const ASN1_OBJECT; + } + } } diff --git a/openssl/src/cms.rs b/openssl/src/cms.rs index a946230a5a..0c2d96cc17 100644 --- a/openssl/src/cms.rs +++ b/openssl/src/cms.rs @@ -10,11 +10,13 @@ use foreign_types::{ForeignType, ForeignTypeRef}; use libc::c_uint; use std::ptr; +use crate::asn1::Asn1ObjectRef; use crate::bio::{MemBio, MemBioSlice}; use crate::error::ErrorStack; use crate::pkey::{HasPrivate, PKeyRef}; use crate::stack::StackRef; use crate::symm::Cipher; +use crate::util::ForeignTypeRefExt; use crate::x509::{store::X509StoreRef, X509Ref, X509}; use crate::{cvt, cvt_p}; use openssl_macros::corresponds; @@ -275,6 +277,15 @@ impl CmsContentInfo { Ok(()) } } + + #[corresponds(CMS_get0_type)] + pub fn get_type(&self) -> &Asn1ObjectRef { + unsafe { + let asn1_type = ffi::CMS_get0_type(self.as_ptr()); + + Asn1ObjectRef::from_const_ptr(asn1_type) + } + } } #[cfg(test)]