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 = "CMSEncoderRef")]
#[repr(C)]
pub struct CMSEncoder {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
cf_type!(
unsafe impl CMSEncoder {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"_CMSEncoder"> for CMSEncoder {}
);
unsafe impl ConcreteType for CMSEncoder {
#[doc(alias = "CMSEncoderGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn CMSEncoderGetTypeID() -> CFTypeID;
}
unsafe { CMSEncoderGetTypeID() }
}
}
impl CMSEncoder {
#[doc(alias = "CMSEncoderCreate")]
#[inline]
pub unsafe fn create(cms_encoder_out: NonNull<*mut CMSEncoder>) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderCreate(cms_encoder_out: NonNull<*mut CMSEncoder>) -> OSStatus;
}
unsafe { CMSEncoderCreate(cms_encoder_out) }
}
}
extern "C" {
pub static kCMSEncoderDigestAlgorithmSHA1: &'static CFString;
}
extern "C" {
pub static kCMSEncoderDigestAlgorithmSHA256: &'static CFString;
}
impl CMSEncoder {
#[doc(alias = "CMSEncoderSetSignerAlgorithm")]
#[inline]
pub unsafe fn set_signer_algorithm(&self, digest_algorithm: &CFString) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderSetSignerAlgorithm(
cms_encoder: &CMSEncoder,
digest_algorithm: &CFString,
) -> OSStatus;
}
unsafe { CMSEncoderSetSignerAlgorithm(self, digest_algorithm) }
}
#[doc(alias = "CMSEncoderAddSigners")]
#[inline]
pub unsafe fn add_signers(&self, signer_or_array: &CFType) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderAddSigners(cms_encoder: &CMSEncoder, signer_or_array: &CFType)
-> OSStatus;
}
unsafe { CMSEncoderAddSigners(self, signer_or_array) }
}
#[doc(alias = "CMSEncoderCopySigners")]
#[inline]
pub unsafe fn copy_signers(&self, signers_out: NonNull<*const CFArray>) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderCopySigners(
cms_encoder: &CMSEncoder,
signers_out: NonNull<*const CFArray>,
) -> OSStatus;
}
unsafe { CMSEncoderCopySigners(self, signers_out) }
}
#[doc(alias = "CMSEncoderAddRecipients")]
#[inline]
pub unsafe fn add_recipients(&self, recipient_or_array: &CFType) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderAddRecipients(
cms_encoder: &CMSEncoder,
recipient_or_array: &CFType,
) -> OSStatus;
}
unsafe { CMSEncoderAddRecipients(self, recipient_or_array) }
}
#[doc(alias = "CMSEncoderCopyRecipients")]
#[inline]
pub unsafe fn copy_recipients(&self, recipients_out: NonNull<*const CFArray>) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderCopyRecipients(
cms_encoder: &CMSEncoder,
recipients_out: NonNull<*const CFArray>,
) -> OSStatus;
}
unsafe { CMSEncoderCopyRecipients(self, recipients_out) }
}
#[doc(alias = "CMSEncoderSetHasDetachedContent")]
#[inline]
pub unsafe fn set_has_detached_content(&self, detached_content: bool) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderSetHasDetachedContent(
cms_encoder: &CMSEncoder,
detached_content: Boolean,
) -> OSStatus;
}
unsafe { CMSEncoderSetHasDetachedContent(self, detached_content as _) }
}
#[doc(alias = "CMSEncoderGetHasDetachedContent")]
#[inline]
pub unsafe fn has_detached_content(&self, detached_content_out: NonNull<Boolean>) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderGetHasDetachedContent(
cms_encoder: &CMSEncoder,
detached_content_out: NonNull<Boolean>,
) -> OSStatus;
}
unsafe { CMSEncoderGetHasDetachedContent(self, detached_content_out) }
}
#[doc(alias = "CMSEncoderSetEncapsulatedContentType")]
#[cfg(feature = "SecAsn1Types")]
#[deprecated]
#[inline]
pub unsafe fn set_encapsulated_content_type(
&self,
e_content_type: NonNull<SecAsn1Oid>,
) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderSetEncapsulatedContentType(
cms_encoder: &CMSEncoder,
e_content_type: NonNull<SecAsn1Oid>,
) -> OSStatus;
}
unsafe { CMSEncoderSetEncapsulatedContentType(self, e_content_type) }
}
#[doc(alias = "CMSEncoderSetEncapsulatedContentTypeOID")]
#[inline]
pub unsafe fn set_encapsulated_content_type_oid(
&self,
e_content_type_oid: &CFType,
) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderSetEncapsulatedContentTypeOID(
cms_encoder: &CMSEncoder,
e_content_type_oid: &CFType,
) -> OSStatus;
}
unsafe { CMSEncoderSetEncapsulatedContentTypeOID(self, e_content_type_oid) }
}
#[doc(alias = "CMSEncoderCopyEncapsulatedContentType")]
#[inline]
pub unsafe fn copy_encapsulated_content_type(
&self,
e_content_type_out: NonNull<*const CFData>,
) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderCopyEncapsulatedContentType(
cms_encoder: &CMSEncoder,
e_content_type_out: NonNull<*const CFData>,
) -> OSStatus;
}
unsafe { CMSEncoderCopyEncapsulatedContentType(self, e_content_type_out) }
}
#[doc(alias = "CMSEncoderAddSupportingCerts")]
#[inline]
pub unsafe fn add_supporting_certs(&self, cert_or_array: &CFType) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderAddSupportingCerts(
cms_encoder: &CMSEncoder,
cert_or_array: &CFType,
) -> OSStatus;
}
unsafe { CMSEncoderAddSupportingCerts(self, cert_or_array) }
}
#[doc(alias = "CMSEncoderCopySupportingCerts")]
#[inline]
pub unsafe fn copy_supporting_certs(&self, certs_out: NonNull<*const CFArray>) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderCopySupportingCerts(
cms_encoder: &CMSEncoder,
certs_out: NonNull<*const CFArray>,
) -> OSStatus;
}
unsafe { CMSEncoderCopySupportingCerts(self, certs_out) }
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CMSSignedAttributes(pub u32);
bitflags::bitflags! {
impl CMSSignedAttributes: u32 {
#[doc(alias = "kCMSAttrNone")]
const AttrNone = 0x0000;
#[doc(alias = "kCMSAttrSmimeCapabilities")]
const AttrSmimeCapabilities = 0x0001;
#[doc(alias = "kCMSAttrSmimeEncryptionKeyPrefs")]
const AttrSmimeEncryptionKeyPrefs = 0x0002;
#[doc(alias = "kCMSAttrSmimeMSEncryptionKeyPrefs")]
const AttrSmimeMSEncryptionKeyPrefs = 0x0004;
#[doc(alias = "kCMSAttrSigningTime")]
const AttrSigningTime = 0x0008;
#[doc(alias = "kCMSAttrAppleCodesigningHashAgility")]
const AttrAppleCodesigningHashAgility = 0x0010;
#[doc(alias = "kCMSAttrAppleCodesigningHashAgilityV2")]
const AttrAppleCodesigningHashAgilityV2 = 0x0020;
#[doc(alias = "kCMSAttrAppleExpirationTime")]
const AttrAppleExpirationTime = 0x0040;
}
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CMSSignedAttributes {
const ENCODING: Encoding = u32::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CMSSignedAttributes {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
impl CMSEncoder {
#[doc(alias = "CMSEncoderAddSignedAttributes")]
#[inline]
pub unsafe fn add_signed_attributes(&self, signed_attributes: CMSSignedAttributes) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderAddSignedAttributes(
cms_encoder: &CMSEncoder,
signed_attributes: CMSSignedAttributes,
) -> OSStatus;
}
unsafe { CMSEncoderAddSignedAttributes(self, signed_attributes) }
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CMSCertificateChainMode(pub u32);
impl CMSCertificateChainMode {
#[doc(alias = "kCMSCertificateNone")]
pub const None: Self = Self(0);
#[doc(alias = "kCMSCertificateSignerOnly")]
pub const SignerOnly: Self = Self(1);
#[doc(alias = "kCMSCertificateChain")]
pub const Chain: Self = Self(2);
#[doc(alias = "kCMSCertificateChainWithRoot")]
pub const ChainWithRoot: Self = Self(3);
#[doc(alias = "kCMSCertificateChainWithRootOrFail")]
pub const ChainWithRootOrFail: Self = Self(4);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CMSCertificateChainMode {
const ENCODING: Encoding = u32::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CMSCertificateChainMode {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
impl CMSEncoder {
#[doc(alias = "CMSEncoderSetCertificateChainMode")]
#[inline]
pub unsafe fn set_certificate_chain_mode(
&self,
chain_mode: CMSCertificateChainMode,
) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderSetCertificateChainMode(
cms_encoder: &CMSEncoder,
chain_mode: CMSCertificateChainMode,
) -> OSStatus;
}
unsafe { CMSEncoderSetCertificateChainMode(self, chain_mode) }
}
#[doc(alias = "CMSEncoderGetCertificateChainMode")]
#[inline]
pub unsafe fn certificate_chain_mode(
&self,
chain_mode_out: NonNull<CMSCertificateChainMode>,
) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderGetCertificateChainMode(
cms_encoder: &CMSEncoder,
chain_mode_out: NonNull<CMSCertificateChainMode>,
) -> OSStatus;
}
unsafe { CMSEncoderGetCertificateChainMode(self, chain_mode_out) }
}
#[doc(alias = "CMSEncoderUpdateContent")]
#[inline]
pub unsafe fn update_content(&self, content: NonNull<c_void>, content_len: usize) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderUpdateContent(
cms_encoder: &CMSEncoder,
content: NonNull<c_void>,
content_len: usize,
) -> OSStatus;
}
unsafe { CMSEncoderUpdateContent(self, content, content_len) }
}
#[doc(alias = "CMSEncoderCopyEncodedContent")]
#[inline]
pub unsafe fn copy_encoded_content(
&self,
encoded_content_out: NonNull<*const CFData>,
) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderCopyEncodedContent(
cms_encoder: &CMSEncoder,
encoded_content_out: NonNull<*const CFData>,
) -> OSStatus;
}
unsafe { CMSEncoderCopyEncodedContent(self, encoded_content_out) }
}
}
#[cfg(feature = "SecAsn1Types")]
#[deprecated]
#[inline]
pub unsafe extern "C-unwind" fn CMSEncode(
signers: Option<&CFType>,
recipients: Option<&CFType>,
e_content_type: *const SecAsn1Oid,
detached_content: bool,
signed_attributes: CMSSignedAttributes,
content: NonNull<c_void>,
content_len: usize,
encoded_content_out: NonNull<*const CFData>,
) -> OSStatus {
extern "C-unwind" {
fn CMSEncode(
signers: Option<&CFType>,
recipients: Option<&CFType>,
e_content_type: *const SecAsn1Oid,
detached_content: Boolean,
signed_attributes: CMSSignedAttributes,
content: NonNull<c_void>,
content_len: usize,
encoded_content_out: NonNull<*const CFData>,
) -> OSStatus;
}
unsafe {
CMSEncode(
signers,
recipients,
e_content_type,
detached_content as _,
signed_attributes,
content,
content_len,
encoded_content_out,
)
}
}
#[inline]
pub unsafe extern "C-unwind" fn CMSEncodeContent(
signers: Option<&CFType>,
recipients: Option<&CFType>,
e_content_type_oid: Option<&CFType>,
detached_content: bool,
signed_attributes: CMSSignedAttributes,
content: NonNull<c_void>,
content_len: usize,
encoded_content_out: *mut *const CFData,
) -> OSStatus {
extern "C-unwind" {
fn CMSEncodeContent(
signers: Option<&CFType>,
recipients: Option<&CFType>,
e_content_type_oid: Option<&CFType>,
detached_content: Boolean,
signed_attributes: CMSSignedAttributes,
content: NonNull<c_void>,
content_len: usize,
encoded_content_out: *mut *const CFData,
) -> OSStatus;
}
unsafe {
CMSEncodeContent(
signers,
recipients,
e_content_type_oid,
detached_content as _,
signed_attributes,
content,
content_len,
encoded_content_out,
)
}
}
impl CMSEncoder {
#[doc(alias = "CMSEncoderCopySignerTimestamp")]
#[inline]
pub unsafe fn copy_signer_timestamp(
&self,
signer_index: usize,
timestamp: NonNull<CFAbsoluteTime>,
) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderCopySignerTimestamp(
cms_encoder: &CMSEncoder,
signer_index: usize,
timestamp: NonNull<CFAbsoluteTime>,
) -> OSStatus;
}
unsafe { CMSEncoderCopySignerTimestamp(self, signer_index, timestamp) }
}
#[doc(alias = "CMSEncoderCopySignerTimestampWithPolicy")]
#[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 CMSEncoderCopySignerTimestampWithPolicy(
cms_encoder: &CMSEncoder,
time_stamp_policy: Option<&CFType>,
signer_index: usize,
timestamp: NonNull<CFAbsoluteTime>,
) -> OSStatus;
}
unsafe {
CMSEncoderCopySignerTimestampWithPolicy(
self,
time_stamp_policy,
signer_index,
timestamp,
)
}
}
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::create`"]
pub fn CMSEncoderCreate(cms_encoder_out: NonNull<*mut CMSEncoder>) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::set_signer_algorithm`"]
pub fn CMSEncoderSetSignerAlgorithm(
cms_encoder: &CMSEncoder,
digest_algorithm: &CFString,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::add_signers`"]
pub fn CMSEncoderAddSigners(cms_encoder: &CMSEncoder, signer_or_array: &CFType) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::copy_signers`"]
pub fn CMSEncoderCopySigners(
cms_encoder: &CMSEncoder,
signers_out: NonNull<*const CFArray>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::add_recipients`"]
pub fn CMSEncoderAddRecipients(
cms_encoder: &CMSEncoder,
recipient_or_array: &CFType,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::copy_recipients`"]
pub fn CMSEncoderCopyRecipients(
cms_encoder: &CMSEncoder,
recipients_out: NonNull<*const CFArray>,
) -> OSStatus;
}
#[deprecated = "renamed to `CMSEncoder::set_has_detached_content`"]
#[inline]
pub unsafe extern "C-unwind" fn CMSEncoderSetHasDetachedContent(
cms_encoder: &CMSEncoder,
detached_content: bool,
) -> OSStatus {
extern "C-unwind" {
fn CMSEncoderSetHasDetachedContent(
cms_encoder: &CMSEncoder,
detached_content: Boolean,
) -> OSStatus;
}
unsafe { CMSEncoderSetHasDetachedContent(cms_encoder, detached_content as _) }
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::has_detached_content`"]
pub fn CMSEncoderGetHasDetachedContent(
cms_encoder: &CMSEncoder,
detached_content_out: NonNull<Boolean>,
) -> OSStatus;
}
extern "C-unwind" {
#[cfg(feature = "SecAsn1Types")]
#[deprecated = "renamed to `CMSEncoder::set_encapsulated_content_type`"]
pub fn CMSEncoderSetEncapsulatedContentType(
cms_encoder: &CMSEncoder,
e_content_type: NonNull<SecAsn1Oid>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::set_encapsulated_content_type_oid`"]
pub fn CMSEncoderSetEncapsulatedContentTypeOID(
cms_encoder: &CMSEncoder,
e_content_type_oid: &CFType,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::copy_encapsulated_content_type`"]
pub fn CMSEncoderCopyEncapsulatedContentType(
cms_encoder: &CMSEncoder,
e_content_type_out: NonNull<*const CFData>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::add_supporting_certs`"]
pub fn CMSEncoderAddSupportingCerts(
cms_encoder: &CMSEncoder,
cert_or_array: &CFType,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::copy_supporting_certs`"]
pub fn CMSEncoderCopySupportingCerts(
cms_encoder: &CMSEncoder,
certs_out: NonNull<*const CFArray>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::add_signed_attributes`"]
pub fn CMSEncoderAddSignedAttributes(
cms_encoder: &CMSEncoder,
signed_attributes: CMSSignedAttributes,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::set_certificate_chain_mode`"]
pub fn CMSEncoderSetCertificateChainMode(
cms_encoder: &CMSEncoder,
chain_mode: CMSCertificateChainMode,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::certificate_chain_mode`"]
pub fn CMSEncoderGetCertificateChainMode(
cms_encoder: &CMSEncoder,
chain_mode_out: NonNull<CMSCertificateChainMode>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::update_content`"]
pub fn CMSEncoderUpdateContent(
cms_encoder: &CMSEncoder,
content: NonNull<c_void>,
content_len: usize,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::copy_encoded_content`"]
pub fn CMSEncoderCopyEncodedContent(
cms_encoder: &CMSEncoder,
encoded_content_out: NonNull<*const CFData>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::copy_signer_timestamp`"]
pub fn CMSEncoderCopySignerTimestamp(
cms_encoder: &CMSEncoder,
signer_index: usize,
timestamp: NonNull<CFAbsoluteTime>,
) -> OSStatus;
}
extern "C-unwind" {
#[deprecated = "renamed to `CMSEncoder::copy_signer_timestamp_with_policy`"]
pub fn CMSEncoderCopySignerTimestampWithPolicy(
cms_encoder: &CMSEncoder,
time_stamp_policy: Option<&CFType>,
signer_index: usize,
timestamp: NonNull<CFAbsoluteTime>,
) -> OSStatus;
}