1use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13#[doc(alias = "CMSDecoderRef")]
15#[repr(C)]
16pub struct CMSDecoder {
17 inner: [u8; 0],
18 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21cf_type!(
22 unsafe impl CMSDecoder {}
23);
24#[cfg(feature = "objc2")]
25cf_objc2_type!(
26 unsafe impl RefEncode<"_CMSDecoder"> for CMSDecoder {}
27);
28
29unsafe impl ConcreteType for CMSDecoder {
30 #[doc(alias = "CMSDecoderGetTypeID")]
31 #[inline]
32 fn type_id() -> CFTypeID {
33 extern "C-unwind" {
34 fn CMSDecoderGetTypeID() -> CFTypeID;
35 }
36 unsafe { CMSDecoderGetTypeID() }
37 }
38}
39
40#[repr(transparent)]
43#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
44pub struct CMSSignerStatus(pub u32);
45impl CMSSignerStatus {
46 #[doc(alias = "kCMSSignerUnsigned")]
47 pub const Unsigned: Self = Self(0);
48 #[doc(alias = "kCMSSignerValid")]
49 pub const Valid: Self = Self(1);
50 #[doc(alias = "kCMSSignerNeedsDetachedContent")]
51 pub const NeedsDetachedContent: Self = Self(2);
52 #[doc(alias = "kCMSSignerInvalidSignature")]
53 pub const InvalidSignature: Self = Self(3);
54 #[doc(alias = "kCMSSignerInvalidCert")]
55 pub const InvalidCert: Self = Self(4);
56 #[doc(alias = "kCMSSignerInvalidIndex")]
57 pub const InvalidIndex: Self = Self(5);
58}
59
60#[cfg(feature = "objc2")]
61unsafe impl Encode for CMSSignerStatus {
62 const ENCODING: Encoding = u32::ENCODING;
63}
64
65#[cfg(feature = "objc2")]
66unsafe impl RefEncode for CMSSignerStatus {
67 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
68}
69
70impl CMSDecoder {
71 #[doc(alias = "CMSDecoderCreate")]
75 #[inline]
76 pub unsafe fn create(cms_decoder_out: NonNull<*mut CMSDecoder>) -> OSStatus {
77 extern "C-unwind" {
78 fn CMSDecoderCreate(cms_decoder_out: NonNull<*mut CMSDecoder>) -> OSStatus;
79 }
80 unsafe { CMSDecoderCreate(cms_decoder_out) }
81 }
82
83 #[doc(alias = "CMSDecoderUpdateMessage")]
87 #[inline]
88 pub unsafe fn update_message(
89 &self,
90 msg_bytes: NonNull<c_void>,
91 msg_bytes_len: usize,
92 ) -> OSStatus {
93 extern "C-unwind" {
94 fn CMSDecoderUpdateMessage(
95 cms_decoder: &CMSDecoder,
96 msg_bytes: NonNull<c_void>,
97 msg_bytes_len: usize,
98 ) -> OSStatus;
99 }
100 unsafe { CMSDecoderUpdateMessage(self, msg_bytes, msg_bytes_len) }
101 }
102
103 #[doc(alias = "CMSDecoderFinalizeMessage")]
104 #[inline]
105 pub unsafe fn finalize_message(&self) -> OSStatus {
106 extern "C-unwind" {
107 fn CMSDecoderFinalizeMessage(cms_decoder: &CMSDecoder) -> OSStatus;
108 }
109 unsafe { CMSDecoderFinalizeMessage(self) }
110 }
111
112 #[doc(alias = "CMSDecoderSetDetachedContent")]
113 #[inline]
114 pub unsafe fn set_detached_content(&self, detached_content: &CFData) -> OSStatus {
115 extern "C-unwind" {
116 fn CMSDecoderSetDetachedContent(
117 cms_decoder: &CMSDecoder,
118 detached_content: &CFData,
119 ) -> OSStatus;
120 }
121 unsafe { CMSDecoderSetDetachedContent(self, detached_content) }
122 }
123
124 #[doc(alias = "CMSDecoderCopyDetachedContent")]
128 #[inline]
129 pub unsafe fn copy_detached_content(
130 &self,
131 detached_content_out: NonNull<*const CFData>,
132 ) -> OSStatus {
133 extern "C-unwind" {
134 fn CMSDecoderCopyDetachedContent(
135 cms_decoder: &CMSDecoder,
136 detached_content_out: NonNull<*const CFData>,
137 ) -> OSStatus;
138 }
139 unsafe { CMSDecoderCopyDetachedContent(self, detached_content_out) }
140 }
141
142 #[doc(alias = "CMSDecoderSetSearchKeychain")]
146 #[deprecated]
147 #[inline]
148 pub unsafe fn set_search_keychain(&self, keychain_or_array: &CFType) -> OSStatus {
149 extern "C-unwind" {
150 fn CMSDecoderSetSearchKeychain(
151 cms_decoder: &CMSDecoder,
152 keychain_or_array: &CFType,
153 ) -> OSStatus;
154 }
155 unsafe { CMSDecoderSetSearchKeychain(self, keychain_or_array) }
156 }
157
158 #[doc(alias = "CMSDecoderGetNumSigners")]
162 #[inline]
163 pub unsafe fn num_signers(&self, num_signers_out: NonNull<usize>) -> OSStatus {
164 extern "C-unwind" {
165 fn CMSDecoderGetNumSigners(
166 cms_decoder: &CMSDecoder,
167 num_signers_out: NonNull<usize>,
168 ) -> OSStatus;
169 }
170 unsafe { CMSDecoderGetNumSigners(self, num_signers_out) }
171 }
172
173 #[doc(alias = "CMSDecoderCopySignerStatus")]
180 #[cfg(feature = "SecTrust")]
181 #[inline]
182 pub unsafe fn copy_signer_status(
183 &self,
184 signer_index: usize,
185 policy_or_array: &CFType,
186 evaluate_sec_trust: bool,
187 signer_status_out: *mut CMSSignerStatus,
188 sec_trust_out: *mut *mut SecTrust,
189 cert_verify_result_code_out: *mut OSStatus,
190 ) -> OSStatus {
191 extern "C-unwind" {
192 fn CMSDecoderCopySignerStatus(
193 cms_decoder: &CMSDecoder,
194 signer_index: usize,
195 policy_or_array: &CFType,
196 evaluate_sec_trust: Boolean,
197 signer_status_out: *mut CMSSignerStatus,
198 sec_trust_out: *mut *mut SecTrust,
199 cert_verify_result_code_out: *mut OSStatus,
200 ) -> OSStatus;
201 }
202 unsafe {
203 CMSDecoderCopySignerStatus(
204 self,
205 signer_index,
206 policy_or_array,
207 evaluate_sec_trust as _,
208 signer_status_out,
209 sec_trust_out,
210 cert_verify_result_code_out,
211 )
212 }
213 }
214
215 #[doc(alias = "CMSDecoderCopySignerEmailAddress")]
219 #[inline]
220 pub unsafe fn copy_signer_email_address(
221 &self,
222 signer_index: usize,
223 signer_email_address_out: NonNull<*const CFString>,
224 ) -> OSStatus {
225 extern "C-unwind" {
226 fn CMSDecoderCopySignerEmailAddress(
227 cms_decoder: &CMSDecoder,
228 signer_index: usize,
229 signer_email_address_out: NonNull<*const CFString>,
230 ) -> OSStatus;
231 }
232 unsafe { CMSDecoderCopySignerEmailAddress(self, signer_index, signer_email_address_out) }
233 }
234
235 #[doc(alias = "CMSDecoderCopySignerCert")]
239 #[cfg(feature = "SecBase")]
240 #[inline]
241 pub unsafe fn copy_signer_cert(
242 &self,
243 signer_index: usize,
244 signer_cert_out: NonNull<*mut SecCertificate>,
245 ) -> OSStatus {
246 extern "C-unwind" {
247 fn CMSDecoderCopySignerCert(
248 cms_decoder: &CMSDecoder,
249 signer_index: usize,
250 signer_cert_out: NonNull<*mut SecCertificate>,
251 ) -> OSStatus;
252 }
253 unsafe { CMSDecoderCopySignerCert(self, signer_index, signer_cert_out) }
254 }
255
256 #[doc(alias = "CMSDecoderIsContentEncrypted")]
260 #[inline]
261 pub unsafe fn is_content_encrypted(&self, is_encrypted_out: NonNull<Boolean>) -> OSStatus {
262 extern "C-unwind" {
263 fn CMSDecoderIsContentEncrypted(
264 cms_decoder: &CMSDecoder,
265 is_encrypted_out: NonNull<Boolean>,
266 ) -> OSStatus;
267 }
268 unsafe { CMSDecoderIsContentEncrypted(self, is_encrypted_out) }
269 }
270
271 #[doc(alias = "CMSDecoderCopyEncapsulatedContentType")]
275 #[inline]
276 pub unsafe fn copy_encapsulated_content_type(
277 &self,
278 e_content_type_out: NonNull<*const CFData>,
279 ) -> OSStatus {
280 extern "C-unwind" {
281 fn CMSDecoderCopyEncapsulatedContentType(
282 cms_decoder: &CMSDecoder,
283 e_content_type_out: NonNull<*const CFData>,
284 ) -> OSStatus;
285 }
286 unsafe { CMSDecoderCopyEncapsulatedContentType(self, e_content_type_out) }
287 }
288
289 #[doc(alias = "CMSDecoderCopyAllCerts")]
293 #[inline]
294 pub unsafe fn copy_all_certs(&self, certs_out: NonNull<*const CFArray>) -> OSStatus {
295 extern "C-unwind" {
296 fn CMSDecoderCopyAllCerts(
297 cms_decoder: &CMSDecoder,
298 certs_out: NonNull<*const CFArray>,
299 ) -> OSStatus;
300 }
301 unsafe { CMSDecoderCopyAllCerts(self, certs_out) }
302 }
303
304 #[doc(alias = "CMSDecoderCopyContent")]
308 #[inline]
309 pub unsafe fn copy_content(&self, content_out: NonNull<*const CFData>) -> OSStatus {
310 extern "C-unwind" {
311 fn CMSDecoderCopyContent(
312 cms_decoder: &CMSDecoder,
313 content_out: NonNull<*const CFData>,
314 ) -> OSStatus;
315 }
316 unsafe { CMSDecoderCopyContent(self, content_out) }
317 }
318
319 #[doc(alias = "CMSDecoderCopySignerSigningTime")]
323 #[inline]
324 pub unsafe fn copy_signer_signing_time(
325 &self,
326 signer_index: usize,
327 signing_time: NonNull<CFAbsoluteTime>,
328 ) -> OSStatus {
329 extern "C-unwind" {
330 fn CMSDecoderCopySignerSigningTime(
331 cms_decoder: &CMSDecoder,
332 signer_index: usize,
333 signing_time: NonNull<CFAbsoluteTime>,
334 ) -> OSStatus;
335 }
336 unsafe { CMSDecoderCopySignerSigningTime(self, signer_index, signing_time) }
337 }
338
339 #[doc(alias = "CMSDecoderCopySignerTimestamp")]
343 #[inline]
344 pub unsafe fn copy_signer_timestamp(
345 &self,
346 signer_index: usize,
347 timestamp: NonNull<CFAbsoluteTime>,
348 ) -> OSStatus {
349 extern "C-unwind" {
350 fn CMSDecoderCopySignerTimestamp(
351 cms_decoder: &CMSDecoder,
352 signer_index: usize,
353 timestamp: NonNull<CFAbsoluteTime>,
354 ) -> OSStatus;
355 }
356 unsafe { CMSDecoderCopySignerTimestamp(self, signer_index, timestamp) }
357 }
358
359 #[doc(alias = "CMSDecoderCopySignerTimestampWithPolicy")]
364 #[inline]
365 pub unsafe fn copy_signer_timestamp_with_policy(
366 &self,
367 time_stamp_policy: Option<&CFType>,
368 signer_index: usize,
369 timestamp: NonNull<CFAbsoluteTime>,
370 ) -> OSStatus {
371 extern "C-unwind" {
372 fn CMSDecoderCopySignerTimestampWithPolicy(
373 cms_decoder: &CMSDecoder,
374 time_stamp_policy: Option<&CFType>,
375 signer_index: usize,
376 timestamp: NonNull<CFAbsoluteTime>,
377 ) -> OSStatus;
378 }
379 unsafe {
380 CMSDecoderCopySignerTimestampWithPolicy(
381 self,
382 time_stamp_policy,
383 signer_index,
384 timestamp,
385 )
386 }
387 }
388
389 #[doc(alias = "CMSDecoderCopySignerTimestampCertificates")]
393 #[inline]
394 pub unsafe fn copy_signer_timestamp_certificates(
395 &self,
396 signer_index: usize,
397 certificate_refs: NonNull<*const CFArray>,
398 ) -> OSStatus {
399 extern "C-unwind" {
400 fn CMSDecoderCopySignerTimestampCertificates(
401 cms_decoder: &CMSDecoder,
402 signer_index: usize,
403 certificate_refs: NonNull<*const CFArray>,
404 ) -> OSStatus;
405 }
406 unsafe { CMSDecoderCopySignerTimestampCertificates(self, signer_index, certificate_refs) }
407 }
408}
409
410extern "C-unwind" {
411 #[deprecated = "renamed to `CMSDecoder::create`"]
412 pub fn CMSDecoderCreate(cms_decoder_out: NonNull<*mut CMSDecoder>) -> OSStatus;
413}
414
415extern "C-unwind" {
416 #[deprecated = "renamed to `CMSDecoder::update_message`"]
417 pub fn CMSDecoderUpdateMessage(
418 cms_decoder: &CMSDecoder,
419 msg_bytes: NonNull<c_void>,
420 msg_bytes_len: usize,
421 ) -> OSStatus;
422}
423
424extern "C-unwind" {
425 #[deprecated = "renamed to `CMSDecoder::finalize_message`"]
426 pub fn CMSDecoderFinalizeMessage(cms_decoder: &CMSDecoder) -> OSStatus;
427}
428
429extern "C-unwind" {
430 #[deprecated = "renamed to `CMSDecoder::set_detached_content`"]
431 pub fn CMSDecoderSetDetachedContent(
432 cms_decoder: &CMSDecoder,
433 detached_content: &CFData,
434 ) -> OSStatus;
435}
436
437extern "C-unwind" {
438 #[deprecated = "renamed to `CMSDecoder::copy_detached_content`"]
439 pub fn CMSDecoderCopyDetachedContent(
440 cms_decoder: &CMSDecoder,
441 detached_content_out: NonNull<*const CFData>,
442 ) -> OSStatus;
443}
444
445extern "C-unwind" {
446 #[deprecated = "renamed to `CMSDecoder::set_search_keychain`"]
447 pub fn CMSDecoderSetSearchKeychain(
448 cms_decoder: &CMSDecoder,
449 keychain_or_array: &CFType,
450 ) -> OSStatus;
451}
452
453extern "C-unwind" {
454 #[deprecated = "renamed to `CMSDecoder::num_signers`"]
455 pub fn CMSDecoderGetNumSigners(
456 cms_decoder: &CMSDecoder,
457 num_signers_out: NonNull<usize>,
458 ) -> OSStatus;
459}
460
461#[cfg(feature = "SecTrust")]
462#[deprecated = "renamed to `CMSDecoder::copy_signer_status`"]
463#[inline]
464pub unsafe extern "C-unwind" fn CMSDecoderCopySignerStatus(
465 cms_decoder: &CMSDecoder,
466 signer_index: usize,
467 policy_or_array: &CFType,
468 evaluate_sec_trust: bool,
469 signer_status_out: *mut CMSSignerStatus,
470 sec_trust_out: *mut *mut SecTrust,
471 cert_verify_result_code_out: *mut OSStatus,
472) -> OSStatus {
473 extern "C-unwind" {
474 fn CMSDecoderCopySignerStatus(
475 cms_decoder: &CMSDecoder,
476 signer_index: usize,
477 policy_or_array: &CFType,
478 evaluate_sec_trust: Boolean,
479 signer_status_out: *mut CMSSignerStatus,
480 sec_trust_out: *mut *mut SecTrust,
481 cert_verify_result_code_out: *mut OSStatus,
482 ) -> OSStatus;
483 }
484 unsafe {
485 CMSDecoderCopySignerStatus(
486 cms_decoder,
487 signer_index,
488 policy_or_array,
489 evaluate_sec_trust as _,
490 signer_status_out,
491 sec_trust_out,
492 cert_verify_result_code_out,
493 )
494 }
495}
496
497extern "C-unwind" {
498 #[deprecated = "renamed to `CMSDecoder::copy_signer_email_address`"]
499 pub fn CMSDecoderCopySignerEmailAddress(
500 cms_decoder: &CMSDecoder,
501 signer_index: usize,
502 signer_email_address_out: NonNull<*const CFString>,
503 ) -> OSStatus;
504}
505
506extern "C-unwind" {
507 #[cfg(feature = "SecBase")]
508 #[deprecated = "renamed to `CMSDecoder::copy_signer_cert`"]
509 pub fn CMSDecoderCopySignerCert(
510 cms_decoder: &CMSDecoder,
511 signer_index: usize,
512 signer_cert_out: NonNull<*mut SecCertificate>,
513 ) -> OSStatus;
514}
515
516extern "C-unwind" {
517 #[deprecated = "renamed to `CMSDecoder::is_content_encrypted`"]
518 pub fn CMSDecoderIsContentEncrypted(
519 cms_decoder: &CMSDecoder,
520 is_encrypted_out: NonNull<Boolean>,
521 ) -> OSStatus;
522}
523
524extern "C-unwind" {
525 #[deprecated = "renamed to `CMSDecoder::copy_encapsulated_content_type`"]
526 pub fn CMSDecoderCopyEncapsulatedContentType(
527 cms_decoder: &CMSDecoder,
528 e_content_type_out: NonNull<*const CFData>,
529 ) -> OSStatus;
530}
531
532extern "C-unwind" {
533 #[deprecated = "renamed to `CMSDecoder::copy_all_certs`"]
534 pub fn CMSDecoderCopyAllCerts(
535 cms_decoder: &CMSDecoder,
536 certs_out: NonNull<*const CFArray>,
537 ) -> OSStatus;
538}
539
540extern "C-unwind" {
541 #[deprecated = "renamed to `CMSDecoder::copy_content`"]
542 pub fn CMSDecoderCopyContent(
543 cms_decoder: &CMSDecoder,
544 content_out: NonNull<*const CFData>,
545 ) -> OSStatus;
546}
547
548extern "C-unwind" {
549 #[deprecated = "renamed to `CMSDecoder::copy_signer_signing_time`"]
550 pub fn CMSDecoderCopySignerSigningTime(
551 cms_decoder: &CMSDecoder,
552 signer_index: usize,
553 signing_time: NonNull<CFAbsoluteTime>,
554 ) -> OSStatus;
555}
556
557extern "C-unwind" {
558 #[deprecated = "renamed to `CMSDecoder::copy_signer_timestamp`"]
559 pub fn CMSDecoderCopySignerTimestamp(
560 cms_decoder: &CMSDecoder,
561 signer_index: usize,
562 timestamp: NonNull<CFAbsoluteTime>,
563 ) -> OSStatus;
564}
565
566extern "C-unwind" {
567 #[deprecated = "renamed to `CMSDecoder::copy_signer_timestamp_with_policy`"]
568 pub fn CMSDecoderCopySignerTimestampWithPolicy(
569 cms_decoder: &CMSDecoder,
570 time_stamp_policy: Option<&CFType>,
571 signer_index: usize,
572 timestamp: NonNull<CFAbsoluteTime>,
573 ) -> OSStatus;
574}
575
576extern "C-unwind" {
577 #[deprecated = "renamed to `CMSDecoder::copy_signer_timestamp_certificates`"]
578 pub fn CMSDecoderCopySignerTimestampCertificates(
579 cms_decoder: &CMSDecoder,
580 signer_index: usize,
581 certificate_refs: NonNull<*const CFArray>,
582 ) -> OSStatus;
583}