1use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7use objc2_core_foundation::*;
8
9use crate::*;
10
11#[cfg(feature = "SecBase")]
12unsafe impl ConcreteType for SecCertificate {
13 #[doc(alias = "SecCertificateGetTypeID")]
17 #[inline]
18 fn type_id() -> CFTypeID {
19 extern "C-unwind" {
20 fn SecCertificateGetTypeID() -> CFTypeID;
21 }
22 unsafe { SecCertificateGetTypeID() }
23 }
24}
25
26#[cfg(feature = "SecBase")]
27impl SecCertificate {
28 #[doc(alias = "SecCertificateCreateWithData")]
37 #[cfg(feature = "SecBase")]
38 #[inline]
39 pub unsafe fn with_data(
40 allocator: Option<&CFAllocator>,
41 data: &CFData,
42 ) -> Option<CFRetained<SecCertificate>> {
43 extern "C-unwind" {
44 fn SecCertificateCreateWithData(
45 allocator: Option<&CFAllocator>,
46 data: &CFData,
47 ) -> Option<NonNull<SecCertificate>>;
48 }
49 let ret = unsafe { SecCertificateCreateWithData(allocator, data) };
50 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
51 }
52
53 #[doc(alias = "SecCertificateCopyData")]
60 #[cfg(feature = "SecBase")]
61 #[inline]
62 pub unsafe fn data(&self) -> CFRetained<CFData> {
63 extern "C-unwind" {
64 fn SecCertificateCopyData(certificate: &SecCertificate) -> Option<NonNull<CFData>>;
65 }
66 let ret = unsafe { SecCertificateCopyData(self) };
67 let ret =
68 ret.expect("function was marked as returning non-null, but actually returned NULL");
69 unsafe { CFRetained::from_raw(ret) }
70 }
71
72 #[doc(alias = "SecCertificateCopySubjectSummary")]
84 #[cfg(feature = "SecBase")]
85 #[inline]
86 pub unsafe fn subject_summary(&self) -> Option<CFRetained<CFString>> {
87 extern "C-unwind" {
88 fn SecCertificateCopySubjectSummary(
89 certificate: &SecCertificate,
90 ) -> Option<NonNull<CFString>>;
91 }
92 let ret = unsafe { SecCertificateCopySubjectSummary(self) };
93 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
94 }
95
96 #[doc(alias = "SecCertificateCopyCommonName")]
112 #[cfg(feature = "SecBase")]
113 #[inline]
114 pub unsafe fn copy_common_name(&self, common_name: NonNull<*const CFString>) -> OSStatus {
115 extern "C-unwind" {
116 fn SecCertificateCopyCommonName(
117 certificate: &SecCertificate,
118 common_name: NonNull<*const CFString>,
119 ) -> OSStatus;
120 }
121 unsafe { SecCertificateCopyCommonName(self, common_name) }
122 }
123
124 #[doc(alias = "SecCertificateCopyEmailAddresses")]
137 #[cfg(feature = "SecBase")]
138 #[inline]
139 pub unsafe fn copy_email_addresses(
140 &self,
141 email_addresses: NonNull<*const CFArray>,
142 ) -> OSStatus {
143 extern "C-unwind" {
144 fn SecCertificateCopyEmailAddresses(
145 certificate: &SecCertificate,
146 email_addresses: NonNull<*const CFArray>,
147 ) -> OSStatus;
148 }
149 unsafe { SecCertificateCopyEmailAddresses(self, email_addresses) }
150 }
151
152 #[doc(alias = "SecCertificateCopyNormalizedIssuerSequence")]
158 #[cfg(feature = "SecBase")]
159 #[inline]
160 pub unsafe fn normalized_issuer_sequence(&self) -> Option<CFRetained<CFData>> {
161 extern "C-unwind" {
162 fn SecCertificateCopyNormalizedIssuerSequence(
163 certificate: &SecCertificate,
164 ) -> Option<NonNull<CFData>>;
165 }
166 let ret = unsafe { SecCertificateCopyNormalizedIssuerSequence(self) };
167 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
168 }
169
170 #[doc(alias = "SecCertificateCopyNormalizedSubjectSequence")]
176 #[cfg(feature = "SecBase")]
177 #[inline]
178 pub unsafe fn normalized_subject_sequence(&self) -> Option<CFRetained<CFData>> {
179 extern "C-unwind" {
180 fn SecCertificateCopyNormalizedSubjectSequence(
181 certificate: &SecCertificate,
182 ) -> Option<NonNull<CFData>>;
183 }
184 let ret = unsafe { SecCertificateCopyNormalizedSubjectSequence(self) };
185 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
186 }
187
188 #[doc(alias = "SecCertificateCopyKey")]
196 #[cfg(feature = "SecBase")]
197 #[inline]
198 pub unsafe fn key(&self) -> Option<CFRetained<SecKey>> {
199 extern "C-unwind" {
200 fn SecCertificateCopyKey(certificate: &SecCertificate) -> Option<NonNull<SecKey>>;
201 }
202 let ret = unsafe { SecCertificateCopyKey(self) };
203 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
204 }
205
206 #[doc(alias = "SecCertificateCopyPublicKey")]
220 #[cfg(feature = "SecBase")]
221 #[deprecated]
222 #[inline]
223 pub unsafe fn copy_public_key(&self, key: NonNull<*mut SecKey>) -> OSStatus {
224 extern "C-unwind" {
225 #[cfg_attr(
226 target_os = "macos",
227 link_name = "SecCertificateCopyPublicKey$LEGACYMAC"
228 )]
229 fn SecCertificateCopyPublicKey(
230 certificate: &SecCertificate,
231 key: NonNull<*mut SecKey>,
232 ) -> OSStatus;
233 }
234 unsafe { SecCertificateCopyPublicKey(self, key) }
235 }
236
237 #[doc(alias = "SecCertificateCopySerialNumberData")]
249 #[cfg(feature = "SecBase")]
250 #[inline]
251 pub unsafe fn serial_number_data(
252 &self,
253 error: *mut *mut CFError,
254 ) -> Option<CFRetained<CFData>> {
255 extern "C-unwind" {
256 fn SecCertificateCopySerialNumberData(
257 certificate: &SecCertificate,
258 error: *mut *mut CFError,
259 ) -> Option<NonNull<CFData>>;
260 }
261 let ret = unsafe { SecCertificateCopySerialNumberData(self, error) };
262 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
263 }
264
265 #[doc(alias = "SecCertificateCopyNotValidBeforeDate")]
272 #[cfg(feature = "SecBase")]
273 #[inline]
274 pub unsafe fn not_valid_before_date(&self) -> Option<CFRetained<CFDate>> {
275 extern "C-unwind" {
276 fn SecCertificateCopyNotValidBeforeDate(
277 certificate: &SecCertificate,
278 ) -> Option<NonNull<CFDate>>;
279 }
280 let ret = unsafe { SecCertificateCopyNotValidBeforeDate(self) };
281 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
282 }
283
284 #[doc(alias = "SecCertificateCopyNotValidAfterDate")]
291 #[cfg(feature = "SecBase")]
292 #[inline]
293 pub unsafe fn not_valid_after_date(&self) -> Option<CFRetained<CFDate>> {
294 extern "C-unwind" {
295 fn SecCertificateCopyNotValidAfterDate(
296 certificate: &SecCertificate,
297 ) -> Option<NonNull<CFDate>>;
298 }
299 let ret = unsafe { SecCertificateCopyNotValidAfterDate(self) };
300 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
301 }
302
303 #[doc(alias = "SecCertificateCopySerialNumber")]
315 #[cfg(feature = "SecBase")]
316 #[deprecated]
317 #[inline]
318 pub unsafe fn serial_number(&self, error: *mut *mut CFError) -> Option<CFRetained<CFData>> {
319 extern "C-unwind" {
320 #[cfg_attr(
321 target_os = "macos",
322 link_name = "SecCertificateCopySerialNumber$LEGACYMAC"
323 )]
324 fn SecCertificateCopySerialNumber(
325 certificate: &SecCertificate,
326 error: *mut *mut CFError,
327 ) -> Option<NonNull<CFData>>;
328 }
329 let ret = unsafe { SecCertificateCopySerialNumber(self, error) };
330 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
331 }
332}
333
334pub const kSecSubjectItemAttr: c_uint = 1937072746;
336pub const kSecIssuerItemAttr: c_uint = 1769173877;
338pub const kSecSerialNumberItemAttr: c_uint = 1936614002;
340pub const kSecPublicKeyHashItemAttr: c_uint = 1752198009;
342pub const kSecSubjectKeyIdentifierItemAttr: c_uint = 1936419172;
344pub const kSecCertTypeItemAttr: c_uint = 1668577648;
346pub const kSecCertEncodingItemAttr: c_uint = 1667591779;
348
349#[cfg(feature = "SecBase")]
350impl SecCertificate {
351 #[doc(alias = "SecCertificateCreateFromData")]
370 #[cfg(all(
371 feature = "SecAsn1Types",
372 feature = "SecBase",
373 feature = "cssmconfig",
374 feature = "cssmtype"
375 ))]
376 #[deprecated]
377 #[inline]
378 pub unsafe fn create_from_data(
379 data: NonNull<SecAsn1Item>,
380 r#type: CSSM_CERT_TYPE,
381 encoding: CSSM_CERT_ENCODING,
382 certificate: NonNull<*mut SecCertificate>,
383 ) -> OSStatus {
384 extern "C-unwind" {
385 fn SecCertificateCreateFromData(
386 data: NonNull<SecAsn1Item>,
387 r#type: CSSM_CERT_TYPE,
388 encoding: CSSM_CERT_ENCODING,
389 certificate: NonNull<*mut SecCertificate>,
390 ) -> OSStatus;
391 }
392 unsafe { SecCertificateCreateFromData(data, r#type, encoding, certificate) }
393 }
394
395 #[doc(alias = "SecCertificateAddToKeychain")]
406 #[cfg(feature = "SecBase")]
407 #[inline]
408 pub unsafe fn add_to_keychain(&self, keychain: Option<&SecKeychain>) -> OSStatus {
409 extern "C-unwind" {
410 fn SecCertificateAddToKeychain(
411 certificate: &SecCertificate,
412 keychain: Option<&SecKeychain>,
413 ) -> OSStatus;
414 }
415 unsafe { SecCertificateAddToKeychain(self, keychain) }
416 }
417
418 #[doc(alias = "SecCertificateGetData")]
432 #[cfg(all(feature = "SecAsn1Types", feature = "SecBase", feature = "cssmtype"))]
433 #[deprecated]
434 #[inline]
435 pub unsafe fn get_data(&self, data: CSSM_DATA_PTR) -> OSStatus {
436 extern "C-unwind" {
437 fn SecCertificateGetData(certificate: &SecCertificate, data: CSSM_DATA_PTR)
438 -> OSStatus;
439 }
440 unsafe { SecCertificateGetData(self, data) }
441 }
442
443 #[doc(alias = "SecCertificateGetType")]
457 #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
458 #[deprecated]
459 #[inline]
460 pub unsafe fn r#type(&self, certificate_type: NonNull<CSSM_CERT_TYPE>) -> OSStatus {
461 extern "C-unwind" {
462 fn SecCertificateGetType(
463 certificate: &SecCertificate,
464 certificate_type: NonNull<CSSM_CERT_TYPE>,
465 ) -> OSStatus;
466 }
467 unsafe { SecCertificateGetType(self, certificate_type) }
468 }
469
470 #[doc(alias = "SecCertificateGetSubject")]
496 #[cfg(all(
497 feature = "SecAsn1Types",
498 feature = "SecBase",
499 feature = "cssmconfig",
500 feature = "x509defs"
501 ))]
502 #[deprecated]
503 #[inline]
504 pub unsafe fn subject(&self, subject: NonNull<*const CSSM_X509_NAME>) -> OSStatus {
505 extern "C-unwind" {
506 fn SecCertificateGetSubject(
507 certificate: &SecCertificate,
508 subject: NonNull<*const CSSM_X509_NAME>,
509 ) -> OSStatus;
510 }
511 unsafe { SecCertificateGetSubject(self, subject) }
512 }
513
514 #[doc(alias = "SecCertificateGetIssuer")]
540 #[cfg(all(
541 feature = "SecAsn1Types",
542 feature = "SecBase",
543 feature = "cssmconfig",
544 feature = "x509defs"
545 ))]
546 #[deprecated]
547 #[inline]
548 pub unsafe fn issuer(&self, issuer: NonNull<*const CSSM_X509_NAME>) -> OSStatus {
549 extern "C-unwind" {
550 fn SecCertificateGetIssuer(
551 certificate: &SecCertificate,
552 issuer: NonNull<*const CSSM_X509_NAME>,
553 ) -> OSStatus;
554 }
555 unsafe { SecCertificateGetIssuer(self, issuer) }
556 }
557
558 #[doc(alias = "SecCertificateGetCLHandle")]
572 #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
573 #[deprecated]
574 #[inline]
575 pub unsafe fn cl_handle(&self, cl_handle: NonNull<CSSM_CL_HANDLE>) -> OSStatus {
576 extern "C-unwind" {
577 fn SecCertificateGetCLHandle(
578 certificate: &SecCertificate,
579 cl_handle: NonNull<CSSM_CL_HANDLE>,
580 ) -> OSStatus;
581 }
582 unsafe { SecCertificateGetCLHandle(self, cl_handle) }
583 }
584
585 #[doc(alias = "SecCertificateGetAlgorithmID")]
598 #[cfg(all(feature = "SecAsn1Types", feature = "SecBase"))]
599 #[deprecated]
600 #[inline]
601 pub unsafe fn algorithm_id(&self, algid: NonNull<*const SecAsn1AlgId>) -> OSStatus {
602 extern "C-unwind" {
603 fn SecCertificateGetAlgorithmID(
604 certificate: &SecCertificate,
605 algid: NonNull<*const SecAsn1AlgId>,
606 ) -> OSStatus;
607 }
608 unsafe { SecCertificateGetAlgorithmID(self, algid) }
609 }
610
611 #[doc(alias = "SecCertificateCopyPreference")]
628 #[cfg(all(feature = "SecBase", feature = "cssmconfig"))]
629 #[deprecated]
630 #[inline]
631 pub unsafe fn copy_preference(
632 name: &CFString,
633 key_usage: uint32,
634 certificate: NonNull<*mut SecCertificate>,
635 ) -> OSStatus {
636 extern "C-unwind" {
637 fn SecCertificateCopyPreference(
638 name: &CFString,
639 key_usage: uint32,
640 certificate: NonNull<*mut SecCertificate>,
641 ) -> OSStatus;
642 }
643 unsafe { SecCertificateCopyPreference(name, key_usage, certificate) }
644 }
645
646 #[doc(alias = "SecCertificateCopyPreferred")]
661 #[cfg(feature = "SecBase")]
662 #[inline]
663 pub unsafe fn preferred(
664 name: &CFString,
665 key_usage: Option<&CFArray>,
666 ) -> Option<CFRetained<SecCertificate>> {
667 extern "C-unwind" {
668 fn SecCertificateCopyPreferred(
669 name: &CFString,
670 key_usage: Option<&CFArray>,
671 ) -> Option<NonNull<SecCertificate>>;
672 }
673 let ret = unsafe { SecCertificateCopyPreferred(name, key_usage) };
674 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
675 }
676
677 #[doc(alias = "SecCertificateSetPreference")]
692 #[cfg(all(feature = "SecBase", feature = "cssmconfig"))]
693 #[deprecated]
694 #[inline]
695 pub unsafe fn set_preference(
696 &self,
697 name: &CFString,
698 key_usage: uint32,
699 date: Option<&CFDate>,
700 ) -> OSStatus {
701 extern "C-unwind" {
702 fn SecCertificateSetPreference(
703 certificate: &SecCertificate,
704 name: &CFString,
705 key_usage: uint32,
706 date: Option<&CFDate>,
707 ) -> OSStatus;
708 }
709 unsafe { SecCertificateSetPreference(self, name, key_usage, date) }
710 }
711
712 #[doc(alias = "SecCertificateSetPreferred")]
729 #[cfg(feature = "SecBase")]
730 #[inline]
731 pub unsafe fn set_preferred(
732 certificate: Option<&SecCertificate>,
733 name: &CFString,
734 key_usage: Option<&CFArray>,
735 ) -> OSStatus {
736 extern "C-unwind" {
737 fn SecCertificateSetPreferred(
738 certificate: Option<&SecCertificate>,
739 name: &CFString,
740 key_usage: Option<&CFArray>,
741 ) -> OSStatus;
742 }
743 unsafe { SecCertificateSetPreferred(certificate, name, key_usage) }
744 }
745}
746
747#[repr(transparent)]
752#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
753pub struct SecKeyUsage(pub u32);
754bitflags::bitflags! {
755 impl SecKeyUsage: u32 {
756 #[doc(alias = "kSecKeyUsageUnspecified")]
757 const Unspecified = 0;
758 #[doc(alias = "kSecKeyUsageDigitalSignature")]
759 const DigitalSignature = 1<<0;
760 #[doc(alias = "kSecKeyUsageNonRepudiation")]
761 const NonRepudiation = 1<<1;
762 #[doc(alias = "kSecKeyUsageContentCommitment")]
763 const ContentCommitment = 1<<1;
764 #[doc(alias = "kSecKeyUsageKeyEncipherment")]
765 const KeyEncipherment = 1<<2;
766 #[doc(alias = "kSecKeyUsageDataEncipherment")]
767 const DataEncipherment = 1<<3;
768 #[doc(alias = "kSecKeyUsageKeyAgreement")]
769 const KeyAgreement = 1<<4;
770 #[doc(alias = "kSecKeyUsageKeyCertSign")]
771 const KeyCertSign = 1<<5;
772 #[doc(alias = "kSecKeyUsageCRLSign")]
773 const CRLSign = 1<<6;
774 #[doc(alias = "kSecKeyUsageEncipherOnly")]
775 const EncipherOnly = 1<<7;
776 #[doc(alias = "kSecKeyUsageDecipherOnly")]
777 const DecipherOnly = 1<<8;
778 #[doc(alias = "kSecKeyUsageCritical")]
779 const Critical = 1<<31;
780 #[doc(alias = "kSecKeyUsageAll")]
781 const All = 0x7FFFFFFF;
782 }
783}
784
785#[cfg(feature = "objc2")]
786unsafe impl Encode for SecKeyUsage {
787 const ENCODING: Encoding = u32::ENCODING;
788}
789
790#[cfg(feature = "objc2")]
791unsafe impl RefEncode for SecKeyUsage {
792 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
793}
794
795extern "C" {
796 pub static kSecPropertyKeyType: &'static CFString;
800}
801
802extern "C" {
803 pub static kSecPropertyKeyLabel: &'static CFString;
805}
806
807extern "C" {
808 pub static kSecPropertyKeyLocalizedLabel: &'static CFString;
810}
811
812extern "C" {
813 pub static kSecPropertyKeyValue: &'static CFString;
815}
816
817extern "C" {
818 pub static kSecPropertyTypeWarning: &'static CFString;
824}
825
826extern "C" {
827 pub static kSecPropertyTypeSuccess: &'static CFString;
829}
830
831extern "C" {
832 pub static kSecPropertyTypeSection: &'static CFString;
834}
835
836extern "C" {
837 pub static kSecPropertyTypeData: &'static CFString;
839}
840
841extern "C" {
842 pub static kSecPropertyTypeString: &'static CFString;
844}
845
846extern "C" {
847 pub static kSecPropertyTypeURL: &'static CFString;
849}
850
851extern "C" {
852 pub static kSecPropertyTypeDate: &'static CFString;
854}
855
856extern "C" {
857 pub static kSecPropertyTypeArray: &'static CFString;
859}
860
861extern "C" {
862 pub static kSecPropertyTypeNumber: &'static CFString;
864}
865
866#[cfg(feature = "SecBase")]
867impl SecCertificate {
868 #[doc(alias = "SecCertificateCopyValues")]
898 #[cfg(feature = "SecBase")]
899 #[inline]
900 pub unsafe fn values(
901 &self,
902 keys: Option<&CFArray>,
903 error: *mut *mut CFError,
904 ) -> Option<CFRetained<CFDictionary>> {
905 extern "C-unwind" {
906 fn SecCertificateCopyValues(
907 certificate: &SecCertificate,
908 keys: Option<&CFArray>,
909 error: *mut *mut CFError,
910 ) -> Option<NonNull<CFDictionary>>;
911 }
912 let ret = unsafe { SecCertificateCopyValues(self, keys, error) };
913 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
914 }
915
916 #[doc(alias = "SecCertificateCopyLongDescription")]
939 #[cfg(feature = "SecBase")]
940 #[inline]
941 pub unsafe fn long_description(
942 alloc: Option<&CFAllocator>,
943 certificate: &SecCertificate,
944 error: *mut *mut CFError,
945 ) -> Option<CFRetained<CFString>> {
946 extern "C-unwind" {
947 fn SecCertificateCopyLongDescription(
948 alloc: Option<&CFAllocator>,
949 certificate: &SecCertificate,
950 error: *mut *mut CFError,
951 ) -> Option<NonNull<CFString>>;
952 }
953 let ret = unsafe { SecCertificateCopyLongDescription(alloc, certificate, error) };
954 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
955 }
956
957 #[doc(alias = "SecCertificateCopyShortDescription")]
980 #[cfg(feature = "SecBase")]
981 #[inline]
982 pub unsafe fn short_description(
983 alloc: Option<&CFAllocator>,
984 certificate: &SecCertificate,
985 error: *mut *mut CFError,
986 ) -> Option<CFRetained<CFString>> {
987 extern "C-unwind" {
988 fn SecCertificateCopyShortDescription(
989 alloc: Option<&CFAllocator>,
990 certificate: &SecCertificate,
991 error: *mut *mut CFError,
992 ) -> Option<NonNull<CFString>>;
993 }
994 let ret = unsafe { SecCertificateCopyShortDescription(alloc, certificate, error) };
995 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
996 }
997
998 #[doc(alias = "SecCertificateCopyNormalizedIssuerContent")]
1016 #[cfg(feature = "SecBase")]
1017 #[deprecated = "SecCertificateCopyNormalizedIssuerContent is deprecated. Use SecCertificateCopyNormalizedIssuerSequence instead."]
1018 #[inline]
1019 pub unsafe fn normalized_issuer_content(
1020 &self,
1021 error: *mut *mut CFError,
1022 ) -> Option<CFRetained<CFData>> {
1023 extern "C-unwind" {
1024 fn SecCertificateCopyNormalizedIssuerContent(
1025 certificate: &SecCertificate,
1026 error: *mut *mut CFError,
1027 ) -> Option<NonNull<CFData>>;
1028 }
1029 let ret = unsafe { SecCertificateCopyNormalizedIssuerContent(self, error) };
1030 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1031 }
1032
1033 #[doc(alias = "SecCertificateCopyNormalizedSubjectContent")]
1051 #[cfg(feature = "SecBase")]
1052 #[deprecated = "SecCertificateCopyNormalizedSubjectContent is deprecated. Use SecCertificateCopyNormalizedSubjectSequence instead."]
1053 #[inline]
1054 pub unsafe fn normalized_subject_content(
1055 &self,
1056 error: *mut *mut CFError,
1057 ) -> Option<CFRetained<CFData>> {
1058 extern "C-unwind" {
1059 fn SecCertificateCopyNormalizedSubjectContent(
1060 certificate: &SecCertificate,
1061 error: *mut *mut CFError,
1062 ) -> Option<NonNull<CFData>>;
1063 }
1064 let ret = unsafe { SecCertificateCopyNormalizedSubjectContent(self, error) };
1065 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1066 }
1067}
1068
1069#[cfg(feature = "SecBase")]
1070#[deprecated = "renamed to `SecCertificate::with_data`"]
1071#[inline]
1072pub unsafe extern "C-unwind" fn SecCertificateCreateWithData(
1073 allocator: Option<&CFAllocator>,
1074 data: &CFData,
1075) -> Option<CFRetained<SecCertificate>> {
1076 extern "C-unwind" {
1077 fn SecCertificateCreateWithData(
1078 allocator: Option<&CFAllocator>,
1079 data: &CFData,
1080 ) -> Option<NonNull<SecCertificate>>;
1081 }
1082 let ret = unsafe { SecCertificateCreateWithData(allocator, data) };
1083 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1084}
1085
1086#[cfg(feature = "SecBase")]
1087#[deprecated = "renamed to `SecCertificate::data`"]
1088#[inline]
1089pub unsafe extern "C-unwind" fn SecCertificateCopyData(
1090 certificate: &SecCertificate,
1091) -> CFRetained<CFData> {
1092 extern "C-unwind" {
1093 fn SecCertificateCopyData(certificate: &SecCertificate) -> Option<NonNull<CFData>>;
1094 }
1095 let ret = unsafe { SecCertificateCopyData(certificate) };
1096 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
1097 unsafe { CFRetained::from_raw(ret) }
1098}
1099
1100#[cfg(feature = "SecBase")]
1101#[deprecated = "renamed to `SecCertificate::subject_summary`"]
1102#[inline]
1103pub unsafe extern "C-unwind" fn SecCertificateCopySubjectSummary(
1104 certificate: &SecCertificate,
1105) -> Option<CFRetained<CFString>> {
1106 extern "C-unwind" {
1107 fn SecCertificateCopySubjectSummary(
1108 certificate: &SecCertificate,
1109 ) -> Option<NonNull<CFString>>;
1110 }
1111 let ret = unsafe { SecCertificateCopySubjectSummary(certificate) };
1112 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1113}
1114
1115extern "C-unwind" {
1116 #[cfg(feature = "SecBase")]
1117 #[deprecated = "renamed to `SecCertificate::copy_common_name`"]
1118 pub fn SecCertificateCopyCommonName(
1119 certificate: &SecCertificate,
1120 common_name: NonNull<*const CFString>,
1121 ) -> OSStatus;
1122}
1123
1124extern "C-unwind" {
1125 #[cfg(feature = "SecBase")]
1126 #[deprecated = "renamed to `SecCertificate::copy_email_addresses`"]
1127 pub fn SecCertificateCopyEmailAddresses(
1128 certificate: &SecCertificate,
1129 email_addresses: NonNull<*const CFArray>,
1130 ) -> OSStatus;
1131}
1132
1133#[cfg(feature = "SecBase")]
1134#[deprecated = "renamed to `SecCertificate::normalized_issuer_sequence`"]
1135#[inline]
1136pub unsafe extern "C-unwind" fn SecCertificateCopyNormalizedIssuerSequence(
1137 certificate: &SecCertificate,
1138) -> Option<CFRetained<CFData>> {
1139 extern "C-unwind" {
1140 fn SecCertificateCopyNormalizedIssuerSequence(
1141 certificate: &SecCertificate,
1142 ) -> Option<NonNull<CFData>>;
1143 }
1144 let ret = unsafe { SecCertificateCopyNormalizedIssuerSequence(certificate) };
1145 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1146}
1147
1148#[cfg(feature = "SecBase")]
1149#[deprecated = "renamed to `SecCertificate::normalized_subject_sequence`"]
1150#[inline]
1151pub unsafe extern "C-unwind" fn SecCertificateCopyNormalizedSubjectSequence(
1152 certificate: &SecCertificate,
1153) -> Option<CFRetained<CFData>> {
1154 extern "C-unwind" {
1155 fn SecCertificateCopyNormalizedSubjectSequence(
1156 certificate: &SecCertificate,
1157 ) -> Option<NonNull<CFData>>;
1158 }
1159 let ret = unsafe { SecCertificateCopyNormalizedSubjectSequence(certificate) };
1160 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1161}
1162
1163#[cfg(feature = "SecBase")]
1164#[deprecated = "renamed to `SecCertificate::key`"]
1165#[inline]
1166pub unsafe extern "C-unwind" fn SecCertificateCopyKey(
1167 certificate: &SecCertificate,
1168) -> Option<CFRetained<SecKey>> {
1169 extern "C-unwind" {
1170 fn SecCertificateCopyKey(certificate: &SecCertificate) -> Option<NonNull<SecKey>>;
1171 }
1172 let ret = unsafe { SecCertificateCopyKey(certificate) };
1173 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1174}
1175
1176extern "C-unwind" {
1177 #[cfg(feature = "SecBase")]
1178 #[deprecated = "renamed to `SecCertificate::copy_public_key`"]
1179 #[cfg_attr(
1180 target_os = "macos",
1181 link_name = "SecCertificateCopyPublicKey$LEGACYMAC"
1182 )]
1183 pub fn SecCertificateCopyPublicKey(
1184 certificate: &SecCertificate,
1185 key: NonNull<*mut SecKey>,
1186 ) -> OSStatus;
1187}
1188
1189#[cfg(feature = "SecBase")]
1190#[deprecated = "renamed to `SecCertificate::serial_number_data`"]
1191#[inline]
1192pub unsafe extern "C-unwind" fn SecCertificateCopySerialNumberData(
1193 certificate: &SecCertificate,
1194 error: *mut *mut CFError,
1195) -> Option<CFRetained<CFData>> {
1196 extern "C-unwind" {
1197 fn SecCertificateCopySerialNumberData(
1198 certificate: &SecCertificate,
1199 error: *mut *mut CFError,
1200 ) -> Option<NonNull<CFData>>;
1201 }
1202 let ret = unsafe { SecCertificateCopySerialNumberData(certificate, error) };
1203 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1204}
1205
1206#[cfg(feature = "SecBase")]
1207#[deprecated = "renamed to `SecCertificate::not_valid_before_date`"]
1208#[inline]
1209pub unsafe extern "C-unwind" fn SecCertificateCopyNotValidBeforeDate(
1210 certificate: &SecCertificate,
1211) -> Option<CFRetained<CFDate>> {
1212 extern "C-unwind" {
1213 fn SecCertificateCopyNotValidBeforeDate(
1214 certificate: &SecCertificate,
1215 ) -> Option<NonNull<CFDate>>;
1216 }
1217 let ret = unsafe { SecCertificateCopyNotValidBeforeDate(certificate) };
1218 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1219}
1220
1221#[cfg(feature = "SecBase")]
1222#[deprecated = "renamed to `SecCertificate::not_valid_after_date`"]
1223#[inline]
1224pub unsafe extern "C-unwind" fn SecCertificateCopyNotValidAfterDate(
1225 certificate: &SecCertificate,
1226) -> Option<CFRetained<CFDate>> {
1227 extern "C-unwind" {
1228 fn SecCertificateCopyNotValidAfterDate(
1229 certificate: &SecCertificate,
1230 ) -> Option<NonNull<CFDate>>;
1231 }
1232 let ret = unsafe { SecCertificateCopyNotValidAfterDate(certificate) };
1233 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1234}
1235
1236#[cfg(feature = "SecBase")]
1237#[deprecated = "renamed to `SecCertificate::serial_number`"]
1238#[inline]
1239pub unsafe extern "C-unwind" fn SecCertificateCopySerialNumber(
1240 certificate: &SecCertificate,
1241 error: *mut *mut CFError,
1242) -> Option<CFRetained<CFData>> {
1243 extern "C-unwind" {
1244 #[cfg_attr(
1245 target_os = "macos",
1246 link_name = "SecCertificateCopySerialNumber$LEGACYMAC"
1247 )]
1248 fn SecCertificateCopySerialNumber(
1249 certificate: &SecCertificate,
1250 error: *mut *mut CFError,
1251 ) -> Option<NonNull<CFData>>;
1252 }
1253 let ret = unsafe { SecCertificateCopySerialNumber(certificate, error) };
1254 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1255}
1256
1257extern "C-unwind" {
1258 #[cfg(all(
1259 feature = "SecAsn1Types",
1260 feature = "SecBase",
1261 feature = "cssmconfig",
1262 feature = "cssmtype"
1263 ))]
1264 #[deprecated = "renamed to `SecCertificate::create_from_data`"]
1265 pub fn SecCertificateCreateFromData(
1266 data: NonNull<SecAsn1Item>,
1267 r#type: CSSM_CERT_TYPE,
1268 encoding: CSSM_CERT_ENCODING,
1269 certificate: NonNull<*mut SecCertificate>,
1270 ) -> OSStatus;
1271}
1272
1273extern "C-unwind" {
1274 #[cfg(feature = "SecBase")]
1275 #[deprecated = "renamed to `SecCertificate::add_to_keychain`"]
1276 pub fn SecCertificateAddToKeychain(
1277 certificate: &SecCertificate,
1278 keychain: Option<&SecKeychain>,
1279 ) -> OSStatus;
1280}
1281
1282extern "C-unwind" {
1283 #[cfg(all(feature = "SecAsn1Types", feature = "SecBase", feature = "cssmtype"))]
1284 #[deprecated = "renamed to `SecCertificate::get_data`"]
1285 pub fn SecCertificateGetData(certificate: &SecCertificate, data: CSSM_DATA_PTR) -> OSStatus;
1286}
1287
1288extern "C-unwind" {
1289 #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
1290 #[deprecated = "renamed to `SecCertificate::type`"]
1291 pub fn SecCertificateGetType(
1292 certificate: &SecCertificate,
1293 certificate_type: NonNull<CSSM_CERT_TYPE>,
1294 ) -> OSStatus;
1295}
1296
1297extern "C-unwind" {
1298 #[cfg(all(
1299 feature = "SecAsn1Types",
1300 feature = "SecBase",
1301 feature = "cssmconfig",
1302 feature = "x509defs"
1303 ))]
1304 #[deprecated = "renamed to `SecCertificate::subject`"]
1305 pub fn SecCertificateGetSubject(
1306 certificate: &SecCertificate,
1307 subject: NonNull<*const CSSM_X509_NAME>,
1308 ) -> OSStatus;
1309}
1310
1311extern "C-unwind" {
1312 #[cfg(all(
1313 feature = "SecAsn1Types",
1314 feature = "SecBase",
1315 feature = "cssmconfig",
1316 feature = "x509defs"
1317 ))]
1318 #[deprecated = "renamed to `SecCertificate::issuer`"]
1319 pub fn SecCertificateGetIssuer(
1320 certificate: &SecCertificate,
1321 issuer: NonNull<*const CSSM_X509_NAME>,
1322 ) -> OSStatus;
1323}
1324
1325extern "C-unwind" {
1326 #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
1327 #[deprecated = "renamed to `SecCertificate::cl_handle`"]
1328 pub fn SecCertificateGetCLHandle(
1329 certificate: &SecCertificate,
1330 cl_handle: NonNull<CSSM_CL_HANDLE>,
1331 ) -> OSStatus;
1332}
1333
1334extern "C-unwind" {
1335 #[cfg(all(feature = "SecAsn1Types", feature = "SecBase"))]
1336 #[deprecated = "renamed to `SecCertificate::algorithm_id`"]
1337 pub fn SecCertificateGetAlgorithmID(
1338 certificate: &SecCertificate,
1339 algid: NonNull<*const SecAsn1AlgId>,
1340 ) -> OSStatus;
1341}
1342
1343extern "C-unwind" {
1344 #[cfg(all(feature = "SecBase", feature = "cssmconfig"))]
1345 #[deprecated = "renamed to `SecCertificate::copy_preference`"]
1346 pub fn SecCertificateCopyPreference(
1347 name: &CFString,
1348 key_usage: uint32,
1349 certificate: NonNull<*mut SecCertificate>,
1350 ) -> OSStatus;
1351}
1352
1353#[cfg(feature = "SecBase")]
1354#[deprecated = "renamed to `SecCertificate::preferred`"]
1355#[inline]
1356pub unsafe extern "C-unwind" fn SecCertificateCopyPreferred(
1357 name: &CFString,
1358 key_usage: Option<&CFArray>,
1359) -> Option<CFRetained<SecCertificate>> {
1360 extern "C-unwind" {
1361 fn SecCertificateCopyPreferred(
1362 name: &CFString,
1363 key_usage: Option<&CFArray>,
1364 ) -> Option<NonNull<SecCertificate>>;
1365 }
1366 let ret = unsafe { SecCertificateCopyPreferred(name, key_usage) };
1367 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1368}
1369
1370extern "C-unwind" {
1371 #[cfg(all(feature = "SecBase", feature = "cssmconfig"))]
1372 #[deprecated = "renamed to `SecCertificate::set_preference`"]
1373 pub fn SecCertificateSetPreference(
1374 certificate: &SecCertificate,
1375 name: &CFString,
1376 key_usage: uint32,
1377 date: Option<&CFDate>,
1378 ) -> OSStatus;
1379}
1380
1381extern "C-unwind" {
1382 #[cfg(feature = "SecBase")]
1383 #[deprecated = "renamed to `SecCertificate::set_preferred`"]
1384 pub fn SecCertificateSetPreferred(
1385 certificate: Option<&SecCertificate>,
1386 name: &CFString,
1387 key_usage: Option<&CFArray>,
1388 ) -> OSStatus;
1389}
1390
1391#[cfg(feature = "SecBase")]
1392#[deprecated = "renamed to `SecCertificate::values`"]
1393#[inline]
1394pub unsafe extern "C-unwind" fn SecCertificateCopyValues(
1395 certificate: &SecCertificate,
1396 keys: Option<&CFArray>,
1397 error: *mut *mut CFError,
1398) -> Option<CFRetained<CFDictionary>> {
1399 extern "C-unwind" {
1400 fn SecCertificateCopyValues(
1401 certificate: &SecCertificate,
1402 keys: Option<&CFArray>,
1403 error: *mut *mut CFError,
1404 ) -> Option<NonNull<CFDictionary>>;
1405 }
1406 let ret = unsafe { SecCertificateCopyValues(certificate, keys, error) };
1407 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1408}
1409
1410#[cfg(feature = "SecBase")]
1411#[deprecated = "renamed to `SecCertificate::long_description`"]
1412#[inline]
1413pub unsafe extern "C-unwind" fn SecCertificateCopyLongDescription(
1414 alloc: Option<&CFAllocator>,
1415 certificate: &SecCertificate,
1416 error: *mut *mut CFError,
1417) -> Option<CFRetained<CFString>> {
1418 extern "C-unwind" {
1419 fn SecCertificateCopyLongDescription(
1420 alloc: Option<&CFAllocator>,
1421 certificate: &SecCertificate,
1422 error: *mut *mut CFError,
1423 ) -> Option<NonNull<CFString>>;
1424 }
1425 let ret = unsafe { SecCertificateCopyLongDescription(alloc, certificate, error) };
1426 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1427}
1428
1429#[cfg(feature = "SecBase")]
1430#[deprecated = "renamed to `SecCertificate::short_description`"]
1431#[inline]
1432pub unsafe extern "C-unwind" fn SecCertificateCopyShortDescription(
1433 alloc: Option<&CFAllocator>,
1434 certificate: &SecCertificate,
1435 error: *mut *mut CFError,
1436) -> Option<CFRetained<CFString>> {
1437 extern "C-unwind" {
1438 fn SecCertificateCopyShortDescription(
1439 alloc: Option<&CFAllocator>,
1440 certificate: &SecCertificate,
1441 error: *mut *mut CFError,
1442 ) -> Option<NonNull<CFString>>;
1443 }
1444 let ret = unsafe { SecCertificateCopyShortDescription(alloc, certificate, error) };
1445 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1446}
1447
1448#[cfg(feature = "SecBase")]
1449#[deprecated = "renamed to `SecCertificate::normalized_issuer_content`"]
1450#[inline]
1451pub unsafe extern "C-unwind" fn SecCertificateCopyNormalizedIssuerContent(
1452 certificate: &SecCertificate,
1453 error: *mut *mut CFError,
1454) -> Option<CFRetained<CFData>> {
1455 extern "C-unwind" {
1456 fn SecCertificateCopyNormalizedIssuerContent(
1457 certificate: &SecCertificate,
1458 error: *mut *mut CFError,
1459 ) -> Option<NonNull<CFData>>;
1460 }
1461 let ret = unsafe { SecCertificateCopyNormalizedIssuerContent(certificate, error) };
1462 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1463}
1464
1465#[cfg(feature = "SecBase")]
1466#[deprecated = "renamed to `SecCertificate::normalized_subject_content`"]
1467#[inline]
1468pub unsafe extern "C-unwind" fn SecCertificateCopyNormalizedSubjectContent(
1469 certificate: &SecCertificate,
1470 error: *mut *mut CFError,
1471) -> Option<CFRetained<CFData>> {
1472 extern "C-unwind" {
1473 fn SecCertificateCopyNormalizedSubjectContent(
1474 certificate: &SecCertificate,
1475 error: *mut *mut CFError,
1476 ) -> Option<NonNull<CFData>>;
1477 }
1478 let ret = unsafe { SecCertificateCopyNormalizedSubjectContent(certificate, error) };
1479 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1480}