use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
use crate::*;
#[doc(alias = "CMSDecoderRef")]
#[repr(C)]
pub struct CMSDecoder {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
cf_type!(
unsafe impl CMSDecoder {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"_CMSDecoder"> for CMSDecoder {}
);
unsafe impl ConcreteType for CMSDecoder {
#[doc(alias = "CMSDecoderGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn CMSDecoderGetTypeID() -> CFTypeID;
}
unsafe { CMSDecoderGetTypeID() }
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CMSSignerStatus(pub u32);
impl CMSSignerStatus {
#[doc(alias = "kCMSSignerUnsigned")]
pub const Unsigned: Self = Self(0);
#[doc(alias = "kCMSSignerValid")]
pub const Valid: Self = Self(1);
#[doc(alias = "kCMSSignerNeedsDetachedContent")]
pub const NeedsDetachedContent: Self = Self(2);
#[doc(alias = "kCMSSignerInvalidSignature")]
pub const InvalidSignature: Self = Self(3);
#[doc(alias = "kCMSSignerInvalidCert")]
pub const InvalidCert: Self = Self(4);
#[doc(alias = "kCMSSignerInvalidIndex")]
pub const InvalidIndex: Self = Self(5);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CMSSignerStatus {
const ENCODING: Encoding = u32::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CMSSignerStatus {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
impl CMSDecoder {
#[doc(alias = "CMSDecoderCreate")]
#[inline]
pub unsafe fn create(cms_decoder_out: NonNull<*mut CMSDecoder>) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCreate(cms_decoder_out: NonNull<*mut CMSDecoder>) -> OSStatus;
}
unsafe { CMSDecoderCreate(cms_decoder_out) }
}
#[doc(alias = "CMSDecoderUpdateMessage")]
#[inline]
pub unsafe fn update_message(
&self,
msg_bytes: NonNull<c_void>,
msg_bytes_len: usize,
) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderUpdateMessage(
cms_decoder: &CMSDecoder,
msg_bytes: NonNull<c_void>,
msg_bytes_len: usize,
) -> OSStatus;
}
unsafe { CMSDecoderUpdateMessage(self, msg_bytes, msg_bytes_len) }
}
#[doc(alias = "CMSDecoderFinalizeMessage")]
#[inline]
pub unsafe fn finalize_message(&self) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderFinalizeMessage(cms_decoder: &CMSDecoder) -> OSStatus;
}
unsafe { CMSDecoderFinalizeMessage(self) }
}
#[doc(alias = "CMSDecoderSetDetachedContent")]
#[inline]
pub unsafe fn set_detached_content(&self, detached_content: &CFData) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderSetDetachedContent(
cms_decoder: &CMSDecoder,
detached_content: &CFData,
) -> OSStatus;
}
unsafe { CMSDecoderSetDetachedContent(self, detached_content) }
}
#[doc(alias = "CMSDecoderCopyDetachedContent")]
#[inline]
pub unsafe fn copy_detached_content(
&self,
detached_content_out: NonNull<*const CFData>,
) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCopyDetachedContent(
cms_decoder: &CMSDecoder,
detached_content_out: NonNull<*const CFData>,
) -> OSStatus;
}
unsafe { CMSDecoderCopyDetachedContent(self, detached_content_out) }
}
#[doc(alias = "CMSDecoderSetSearchKeychain")]
#[deprecated]
#[inline]
pub unsafe fn set_search_keychain(&self, keychain_or_array: &CFType) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderSetSearchKeychain(
cms_decoder: &CMSDecoder,
keychain_or_array: &CFType,
) -> OSStatus;
}
unsafe { CMSDecoderSetSearchKeychain(self, keychain_or_array) }
}
#[doc(alias = "CMSDecoderGetNumSigners")]
#[inline]
pub unsafe fn num_signers(&self, num_signers_out: NonNull<usize>) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderGetNumSigners(
cms_decoder: &CMSDecoder,
num_signers_out: NonNull<usize>,
) -> OSStatus;
}
unsafe { CMSDecoderGetNumSigners(self, num_signers_out) }
}
#[doc(alias = "CMSDecoderCopySignerStatus")]
#[cfg(feature = "SecTrust")]
#[inline]
pub unsafe fn copy_signer_status(
&self,
signer_index: usize,
policy_or_array: &CFType,
evaluate_sec_trust: bool,
signer_status_out: *mut CMSSignerStatus,
sec_trust_out: *mut *mut SecTrust,
cert_verify_result_code_out: *mut OSStatus,
) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCopySignerStatus(
cms_decoder: &CMSDecoder,
signer_index: usize,
policy_or_array: &CFType,
evaluate_sec_trust: Boolean,
signer_status_out: *mut CMSSignerStatus,
sec_trust_out: *mut *mut SecTrust,
cert_verify_result_code_out: *mut OSStatus,
) -> OSStatus;
}
unsafe {
CMSDecoderCopySignerStatus(
self,
signer_index,
policy_or_array,
evaluate_sec_trust as _,
signer_status_out,
sec_trust_out,
cert_verify_result_code_out,
)
}
}
#[doc(alias = "CMSDecoderCopySignerEmailAddress")]
#[inline]
pub unsafe fn copy_signer_email_address(
&self,
signer_index: usize,
signer_email_address_out: NonNull<*const CFString>,
) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCopySignerEmailAddress(
cms_decoder: &CMSDecoder,
signer_index: usize,
signer_email_address_out: NonNull<*const CFString>,
) -> OSStatus;
}
unsafe { CMSDecoderCopySignerEmailAddress(self, signer_index, signer_email_address_out) }
}
#[doc(alias = "CMSDecoderCopySignerCert")]
#[cfg(feature = "SecBase")]
#[inline]
pub unsafe fn copy_signer_cert(
&self,
signer_index: usize,
signer_cert_out: NonNull<*mut SecCertificate>,
) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCopySignerCert(
cms_decoder: &CMSDecoder,
signer_index: usize,
signer_cert_out: NonNull<*mut SecCertificate>,
) -> OSStatus;
}
unsafe { CMSDecoderCopySignerCert(self, signer_index, signer_cert_out) }
}
#[doc(alias = "CMSDecoderIsContentEncrypted")]
#[inline]
pub unsafe fn is_content_encrypted(&self, is_encrypted_out: NonNull<Boolean>) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderIsContentEncrypted(
cms_decoder: &CMSDecoder,
is_encrypted_out: NonNull<Boolean>,
) -> OSStatus;
}
unsafe { CMSDecoderIsContentEncrypted(self, is_encrypted_out) }
}
#[doc(alias = "CMSDecoderCopyEncapsulatedContentType")]
#[inline]
pub unsafe fn copy_encapsulated_content_type(
&self,
e_content_type_out: NonNull<*const CFData>,
) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCopyEncapsulatedContentType(
cms_decoder: &CMSDecoder,
e_content_type_out: NonNull<*const CFData>,
) -> OSStatus;
}
unsafe { CMSDecoderCopyEncapsulatedContentType(self, e_content_type_out) }
}
#[doc(alias = "CMSDecoderCopyAllCerts")]
#[inline]
pub unsafe fn copy_all_certs(&self, certs_out: NonNull<*const CFArray>) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCopyAllCerts(
cms_decoder: &CMSDecoder,
certs_out: NonNull<*const CFArray>,
) -> OSStatus;
}
unsafe { CMSDecoderCopyAllCerts(self, certs_out) }
}
#[doc(alias = "CMSDecoderCopyContent")]
#[inline]
pub unsafe fn copy_content(&self, content_out: NonNull<*const CFData>) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCopyContent(
cms_decoder: &CMSDecoder,
content_out: NonNull<*const CFData>,
) -> OSStatus;
}
unsafe { CMSDecoderCopyContent(self, content_out) }
}
#[doc(alias = "CMSDecoderCopySignerSigningTime")]
#[inline]
pub unsafe fn copy_signer_signing_time(
&self,
signer_index: usize,
signing_time: NonNull<CFAbsoluteTime>,
) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCopySignerSigningTime(
cms_decoder: &CMSDecoder,
signer_index: usize,
signing_time: NonNull<CFAbsoluteTime>,
) -> OSStatus;
}
unsafe { CMSDecoderCopySignerSigningTime(self, signer_index, signing_time) }
}
#[doc(alias = "CMSDecoderCopySignerTimestamp")]
#[inline]
pub unsafe fn copy_signer_timestamp(
&self,
signer_index: usize,
timestamp: NonNull<CFAbsoluteTime>,
) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCopySignerTimestamp(
cms_decoder: &CMSDecoder,
signer_index: usize,
timestamp: NonNull<CFAbsoluteTime>,
) -> OSStatus;
}
unsafe { CMSDecoderCopySignerTimestamp(self, signer_index, timestamp) }
}
#[doc(alias = "CMSDecoderCopySignerTimestampWithPolicy")]
#[inline]
pub unsafe fn copy_signer_timestamp_with_policy(
&self,
time_stamp_policy: Option<&CFType>,
signer_index: usize,
timestamp: NonNull<CFAbsoluteTime>,
) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCopySignerTimestampWithPolicy(
cms_decoder: &CMSDecoder,
time_stamp_policy: Option<&CFType>,
signer_index: usize,
timestamp: NonNull<CFAbsoluteTime>,
) -> OSStatus;
}
unsafe {
CMSDecoderCopySignerTimestampWithPolicy(
self,
time_stamp_policy,
signer_index,
timestamp,
)
}
}
#[doc(alias = "CMSDecoderCopySignerTimestampCertificates")]
#[inline]
pub unsafe fn copy_signer_timestamp_certificates(
&self,
signer_index: usize,
certificate_refs: NonNull<*const CFArray>,
) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCopySignerTimestampCertificates(
cms_decoder: &CMSDecoder,
signer_index: usize,
certificate_refs: NonNull<*const CFArray>,
) -> OSStatus;
}
unsafe { CMSDecoderCopySignerTimestampCertificates(self, signer_index, certificate_refs) }
}
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::create`"]
pub fn CMSDecoderCreate(cms_decoder_out: NonNull<*mut CMSDecoder>) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::update_message`"]
pub fn CMSDecoderUpdateMessage(
cms_decoder: &CMSDecoder,
msg_bytes: NonNull<c_void>,
msg_bytes_len: usize,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::finalize_message`"]
pub fn CMSDecoderFinalizeMessage(cms_decoder: &CMSDecoder) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::set_detached_content`"]
pub fn CMSDecoderSetDetachedContent(
cms_decoder: &CMSDecoder,
detached_content: &CFData,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::copy_detached_content`"]
pub fn CMSDecoderCopyDetachedContent(
cms_decoder: &CMSDecoder,
detached_content_out: NonNull<*const CFData>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::set_search_keychain`"]
pub fn CMSDecoderSetSearchKeychain(
cms_decoder: &CMSDecoder,
keychain_or_array: &CFType,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::num_signers`"]
pub fn CMSDecoderGetNumSigners(
cms_decoder: &CMSDecoder,
num_signers_out: NonNull<usize>,
) -> OSStatus;
}
#[cfg(feature = "SecTrust")]
#[deprecated = "renamed to `CMSDecoder::copy_signer_status`"]
#[inline]
pub unsafe extern "C-unwind" fn CMSDecoderCopySignerStatus(
cms_decoder: &CMSDecoder,
signer_index: usize,
policy_or_array: &CFType,
evaluate_sec_trust: bool,
signer_status_out: *mut CMSSignerStatus,
sec_trust_out: *mut *mut SecTrust,
cert_verify_result_code_out: *mut OSStatus,
) -> OSStatus {
extern "C-unwind" {
fn CMSDecoderCopySignerStatus(
cms_decoder: &CMSDecoder,
signer_index: usize,
policy_or_array: &CFType,
evaluate_sec_trust: Boolean,
signer_status_out: *mut CMSSignerStatus,
sec_trust_out: *mut *mut SecTrust,
cert_verify_result_code_out: *mut OSStatus,
) -> OSStatus;
}
unsafe {
CMSDecoderCopySignerStatus(
cms_decoder,
signer_index,
policy_or_array,
evaluate_sec_trust as _,
signer_status_out,
sec_trust_out,
cert_verify_result_code_out,
)
}
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::copy_signer_email_address`"]
pub fn CMSDecoderCopySignerEmailAddress(
cms_decoder: &CMSDecoder,
signer_index: usize,
signer_email_address_out: NonNull<*const CFString>,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecBase")]
#[deprecated = "renamed to `CMSDecoder::copy_signer_cert`"]
pub fn CMSDecoderCopySignerCert(
cms_decoder: &CMSDecoder,
signer_index: usize,
signer_cert_out: NonNull<*mut SecCertificate>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::is_content_encrypted`"]
pub fn CMSDecoderIsContentEncrypted(
cms_decoder: &CMSDecoder,
is_encrypted_out: NonNull<Boolean>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::copy_encapsulated_content_type`"]
pub fn CMSDecoderCopyEncapsulatedContentType(
cms_decoder: &CMSDecoder,
e_content_type_out: NonNull<*const CFData>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::copy_all_certs`"]
pub fn CMSDecoderCopyAllCerts(
cms_decoder: &CMSDecoder,
certs_out: NonNull<*const CFArray>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::copy_content`"]
pub fn CMSDecoderCopyContent(
cms_decoder: &CMSDecoder,
content_out: NonNull<*const CFData>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::copy_signer_signing_time`"]
pub fn CMSDecoderCopySignerSigningTime(
cms_decoder: &CMSDecoder,
signer_index: usize,
signing_time: NonNull<CFAbsoluteTime>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::copy_signer_timestamp`"]
pub fn CMSDecoderCopySignerTimestamp(
cms_decoder: &CMSDecoder,
signer_index: usize,
timestamp: NonNull<CFAbsoluteTime>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::copy_signer_timestamp_with_policy`"]
pub fn CMSDecoderCopySignerTimestampWithPolicy(
cms_decoder: &CMSDecoder,
time_stamp_policy: Option<&CFType>,
signer_index: usize,
timestamp: NonNull<CFAbsoluteTime>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSDecoder::copy_signer_timestamp_certificates`"]
pub fn CMSDecoderCopySignerTimestampCertificates(
cms_decoder: &CMSDecoder,
signer_index: usize,
certificate_refs: NonNull<*const CFArray>,
) -> OSStatus;
}