objc2_security/generated/
SecPolicy.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2_core_foundation::*;
5
6use crate::*;
7
8extern "C" {
9    /// Predefined constants used to specify a policy.
10    ///
11    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyapplex509basic?language=objc)
12    pub static kSecPolicyAppleX509Basic: &'static CFString;
13}
14
15extern "C" {
16    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyapplessl?language=objc)
17    pub static kSecPolicyAppleSSL: &'static CFString;
18}
19
20extern "C" {
21    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyapplesmime?language=objc)
22    pub static kSecPolicyAppleSMIME: &'static CFString;
23}
24
25extern "C" {
26    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyappleeap?language=objc)
27    pub static kSecPolicyAppleEAP: &'static CFString;
28}
29
30extern "C" {
31    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyappleipsec?language=objc)
32    pub static kSecPolicyAppleIPsec: &'static CFString;
33}
34
35extern "C" {
36    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyappleichat?language=objc)
37    #[deprecated]
38    pub static kSecPolicyAppleiChat: &'static CFString;
39}
40
41extern "C" {
42    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyapplepkinitclient?language=objc)
43    pub static kSecPolicyApplePKINITClient: &'static CFString;
44}
45
46extern "C" {
47    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyapplepkinitserver?language=objc)
48    pub static kSecPolicyApplePKINITServer: &'static CFString;
49}
50
51extern "C" {
52    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyapplecodesigning?language=objc)
53    pub static kSecPolicyAppleCodeSigning: &'static CFString;
54}
55
56extern "C" {
57    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicymacappstorereceipt?language=objc)
58    pub static kSecPolicyMacAppStoreReceipt: &'static CFString;
59}
60
61extern "C" {
62    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyappleidvalidation?language=objc)
63    pub static kSecPolicyAppleIDValidation: &'static CFString;
64}
65
66extern "C" {
67    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyappletimestamping?language=objc)
68    pub static kSecPolicyAppleTimeStamping: &'static CFString;
69}
70
71extern "C" {
72    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyapplerevocation?language=objc)
73    pub static kSecPolicyAppleRevocation: &'static CFString;
74}
75
76extern "C" {
77    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyapplepassbooksigning?language=objc)
78    pub static kSecPolicyApplePassbookSigning: &'static CFString;
79}
80
81extern "C" {
82    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyapplepayissuerencryption?language=objc)
83    pub static kSecPolicyApplePayIssuerEncryption: &'static CFString;
84}
85
86extern "C" {
87    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyapplesslserver?language=objc)
88    pub static kSecPolicyAppleSSLServer: &'static CFString;
89}
90
91extern "C" {
92    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyapplesslclient?language=objc)
93    pub static kSecPolicyAppleSSLClient: &'static CFString;
94}
95
96extern "C" {
97    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyappleeapserver?language=objc)
98    pub static kSecPolicyAppleEAPServer: &'static CFString;
99}
100
101extern "C" {
102    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyappleeapclient?language=objc)
103    pub static kSecPolicyAppleEAPClient: &'static CFString;
104}
105
106extern "C" {
107    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyappleipsecserver?language=objc)
108    pub static kSecPolicyAppleIPSecServer: &'static CFString;
109}
110
111extern "C" {
112    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyappleipsecclient?language=objc)
113    pub static kSecPolicyAppleIPSecClient: &'static CFString;
114}
115
116extern "C" {
117    /// Predefined property key constants used to get or set values in
118    /// a dictionary for a policy instance.
119    ///
120    /// All policies will have the following read-only value:
121    /// kSecPolicyOid       (the policy object identifier)
122    ///
123    /// Additional policy values which your code can optionally set:
124    /// kSecPolicyName      (name which must be matched)
125    /// kSecPolicyClient    (evaluate for client, rather than server)
126    /// kSecPolicyRevocationFlags   (only valid for a revocation policy)
127    /// kSecPolicyTeamIdentifier    (only valid for a Passbook signing policy)
128    ///
129    ///
130    ///
131    /// containing a name which must be matched in the certificate to satisfy
132    /// this policy. For SSL/TLS, EAP, and IPSec policies, this specifies the
133    /// server name which must match the common name of the certificate.
134    /// For S/MIME, this specifies the RFC822 email address. For Passbook
135    /// signing, this specifies the pass signer.
136    ///
137    /// this evaluation should be for a client certificate. If not set (or
138    /// false), the policy evaluates the certificate as a server certificate.
139    ///
140    /// kCFNumberCFIndexType bitmask value. See "Revocation Policy Constants"
141    /// for a description of individual bits in this value.
142    ///
143    /// team identifier which must be matched in the certificate to satisfy
144    /// this policy. For the Passbook signing policy, this string must match
145    /// the Organizational Unit field of the certificate subject.
146    ///
147    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyoid?language=objc)
148    pub static kSecPolicyOid: &'static CFString;
149}
150
151extern "C" {
152    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyname?language=objc)
153    pub static kSecPolicyName: &'static CFString;
154}
155
156extern "C" {
157    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyclient?language=objc)
158    pub static kSecPolicyClient: &'static CFString;
159}
160
161extern "C" {
162    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyrevocationflags?language=objc)
163    pub static kSecPolicyRevocationFlags: &'static CFString;
164}
165
166extern "C" {
167    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyteamidentifier?language=objc)
168    pub static kSecPolicyTeamIdentifier: &'static CFString;
169}
170
171#[cfg(feature = "SecBase")]
172unsafe impl ConcreteType for SecPolicy {
173    /// Returns the type identifier of SecPolicy instances.
174    ///
175    /// Returns: The CFTypeID of SecPolicy instances.
176    #[doc(alias = "SecPolicyGetTypeID")]
177    #[inline]
178    fn type_id() -> CFTypeID {
179        extern "C-unwind" {
180            fn SecPolicyGetTypeID() -> CFTypeID;
181        }
182        unsafe { SecPolicyGetTypeID() }
183    }
184}
185
186#[cfg(feature = "SecBase")]
187impl SecPolicy {
188    /// Returns a dictionary of this policy's properties.
189    ///
190    /// Parameter `policyRef`: A policy reference.
191    ///
192    /// Returns: A properties dictionary. See "Policy Value Constants" for a list
193    /// of currently defined property keys. It is the caller's responsibility to
194    /// CFRelease this reference when it is no longer needed.
195    ///
196    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
197    ///
198    /// This function returns the properties for a policy, as set by the
199    /// policy's construction function or by a prior call to SecPolicySetProperties.
200    #[doc(alias = "SecPolicyCopyProperties")]
201    #[cfg(feature = "SecBase")]
202    #[inline]
203    pub unsafe fn properties(&self) -> Option<CFRetained<CFDictionary>> {
204        extern "C-unwind" {
205            fn SecPolicyCopyProperties(policy_ref: &SecPolicy) -> Option<NonNull<CFDictionary>>;
206        }
207        let ret = unsafe { SecPolicyCopyProperties(self) };
208        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
209    }
210
211    /// Returns a policy object for the default X.509 policy.
212    ///
213    /// Returns: A policy object. The caller is responsible for calling CFRelease
214    /// on this when it is no longer needed.
215    #[doc(alias = "SecPolicyCreateBasicX509")]
216    #[cfg(feature = "SecBase")]
217    #[inline]
218    pub unsafe fn new_basic_x509() -> CFRetained<SecPolicy> {
219        extern "C-unwind" {
220            fn SecPolicyCreateBasicX509() -> Option<NonNull<SecPolicy>>;
221        }
222        let ret = unsafe { SecPolicyCreateBasicX509() };
223        let ret =
224            ret.expect("function was marked as returning non-null, but actually returned NULL");
225        unsafe { CFRetained::from_raw(ret) }
226    }
227
228    /// Returns a policy object for evaluating SSL certificate chains.
229    ///
230    /// Parameter `server`: Passing true for this parameter creates a policy for SSL
231    /// server certificates.
232    ///
233    /// Parameter `hostname`: (Optional) If present, the policy will require the specified
234    /// hostname to match the hostname in the leaf certificate.
235    ///
236    /// Returns: A policy object. The caller is responsible for calling CFRelease
237    /// on this when it is no longer needed.
238    #[doc(alias = "SecPolicyCreateSSL")]
239    #[cfg(feature = "SecBase")]
240    #[inline]
241    pub unsafe fn new_ssl(server: bool, hostname: Option<&CFString>) -> CFRetained<SecPolicy> {
242        extern "C-unwind" {
243            fn SecPolicyCreateSSL(
244                server: Boolean,
245                hostname: Option<&CFString>,
246            ) -> Option<NonNull<SecPolicy>>;
247        }
248        let ret = unsafe { SecPolicyCreateSSL(server as _, hostname) };
249        let ret =
250            ret.expect("function was marked as returning non-null, but actually returned NULL");
251        unsafe { CFRetained::from_raw(ret) }
252    }
253}
254
255/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecrevocationocspmethod?language=objc)
256pub const kSecRevocationOCSPMethod: CFOptionFlags = 1;
257/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecrevocationcrlmethod?language=objc)
258pub const kSecRevocationCRLMethod: CFOptionFlags = 2;
259/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecrevocationprefercrl?language=objc)
260pub const kSecRevocationPreferCRL: CFOptionFlags = 4;
261/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecrevocationrequirepositiveresponse?language=objc)
262pub const kSecRevocationRequirePositiveResponse: CFOptionFlags = 8;
263/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecrevocationnetworkaccessdisabled?language=objc)
264pub const kSecRevocationNetworkAccessDisabled: CFOptionFlags = 16;
265/// [Apple's documentation](https://developer.apple.com/documentation/security/ksecrevocationuseanyavailablemethod?language=objc)
266pub const kSecRevocationUseAnyAvailableMethod: CFOptionFlags = 3;
267
268#[cfg(feature = "SecBase")]
269impl SecPolicy {
270    /// Returns a policy object for checking revocation of certificates.
271    ///
272    /// Returns: A policy object. The caller is responsible for calling CFRelease
273    /// on this when it is no longer needed.
274    ///
275    /// Parameter `revocationFlags`: Flags to specify revocation checking options.
276    ///
277    /// Use this function to create a revocation policy with behavior
278    /// specified by revocationFlags. See the "Revocation Policy Constants" section
279    /// for a description of these flags. Note: it is usually not necessary to
280    /// create a revocation policy yourself unless you wish to override default
281    /// system behavior (e.g. to force a particular method, or to disable
282    /// revocation checking entirely.)
283    #[doc(alias = "SecPolicyCreateRevocation")]
284    #[cfg(feature = "SecBase")]
285    #[inline]
286    pub unsafe fn new_revocation(revocation_flags: CFOptionFlags) -> Option<CFRetained<SecPolicy>> {
287        extern "C-unwind" {
288            fn SecPolicyCreateRevocation(
289                revocation_flags: CFOptionFlags,
290            ) -> Option<NonNull<SecPolicy>>;
291        }
292        let ret = unsafe { SecPolicyCreateRevocation(revocation_flags) };
293        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
294    }
295
296    /// Returns a policy object based on an object identifier for the
297    /// policy type. See the "Policy Constants" section for a list of defined
298    /// policy object identifiers.
299    ///
300    /// Parameter `policyIdentifier`: The identifier for the desired policy type.
301    ///
302    /// Parameter `properties`: (Optional) A properties dictionary. See "Policy Value
303    /// Constants" for a list of currently defined property keys.
304    ///
305    /// Returns: The returned policy reference, or NULL if the policy could not be
306    /// created.
307    ///
308    /// # Safety
309    ///
310    /// - `policy_identifier` should be of the correct type.
311    /// - `properties` generics must be of the correct type.
312    #[doc(alias = "SecPolicyCreateWithProperties")]
313    #[cfg(feature = "SecBase")]
314    #[inline]
315    pub unsafe fn with_properties(
316        policy_identifier: &CFType,
317        properties: Option<&CFDictionary>,
318    ) -> Option<CFRetained<SecPolicy>> {
319        extern "C-unwind" {
320            fn SecPolicyCreateWithProperties(
321                policy_identifier: &CFType,
322                properties: Option<&CFDictionary>,
323            ) -> Option<NonNull<SecPolicy>>;
324        }
325        let ret = unsafe { SecPolicyCreateWithProperties(policy_identifier, properties) };
326        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
327    }
328}
329
330extern "C" {
331    /// Predefined property key constants used to get or set values in
332    /// a dictionary for a policy instance.
333    ///
334    /// Some policy values may specify CFBooleanRef key usage constraints:
335    /// kSecPolicyKU_DigitalSignature
336    /// kSecPolicyKU_NonRepudiation
337    /// kSecPolicyKU_KeyEncipherment
338    /// kSecPolicyKU_DataEncipherment
339    /// kSecPolicyKU_KeyAgreement
340    /// kSecPolicyKU_KeyCertSign
341    /// kSecPolicyKU_CRLSign
342    /// kSecPolicyKU_EncipherOnly
343    /// kSecPolicyKU_DecipherOnly
344    ///
345    /// kSecPolicyKU policy values define certificate-level key purposes,
346    /// in contrast to the key-level definitions in SecItem.h
347    ///
348    /// For example, a key in a certificate might be acceptable to use for
349    /// signing a CRL, but not for signing another certificate. In either
350    /// case, this key would have the ability to sign (i.e. kSecAttrCanSign
351    /// is true), but may only sign for specific purposes allowed by these
352    /// policy constants. Similarly, a public key might have the capability
353    /// to perform encryption or decryption, but the certificate in which it
354    /// resides might have a decipher-only certificate policy.
355    ///
356    /// These constants correspond to values defined in RFC 5280, section
357    /// 4.2.1.3 (Key Usage) which define the purpose of a key contained in a
358    /// certificate, in contrast to section 4.1.2.7 which define the uses that
359    /// a key is capable of.
360    ///
361    /// Note: these constants are not available on iOS. Your code should
362    /// avoid direct reliance on these values for making policy decisions
363    /// and use higher level policies where possible.
364    ///
365    ///
366    /// have a key usage that allows it to be used for signing.
367    ///
368    /// have a key usage that allows it to be used for non-repudiation.
369    ///
370    /// have a key usage that allows it to be used for key encipherment.
371    ///
372    /// have a key usage that allows it to be used for data encipherment.
373    ///
374    /// have a key usage that allows it to be used for key agreement.
375    ///
376    /// have a key usage that allows it to be used for signing certificates.
377    ///
378    /// have a key usage that allows it to be used for signing CRLs.
379    ///
380    /// have a key usage that permits it to be used for encryption only.
381    ///
382    /// have a key usage that permits it to be used for decryption only.
383    ///
384    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyku_digitalsignature?language=objc)
385    pub static kSecPolicyKU_DigitalSignature: &'static CFString;
386}
387
388extern "C" {
389    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyku_nonrepudiation?language=objc)
390    pub static kSecPolicyKU_NonRepudiation: &'static CFString;
391}
392
393extern "C" {
394    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyku_keyencipherment?language=objc)
395    pub static kSecPolicyKU_KeyEncipherment: &'static CFString;
396}
397
398extern "C" {
399    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyku_dataencipherment?language=objc)
400    pub static kSecPolicyKU_DataEncipherment: &'static CFString;
401}
402
403extern "C" {
404    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyku_keyagreement?language=objc)
405    pub static kSecPolicyKU_KeyAgreement: &'static CFString;
406}
407
408extern "C" {
409    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyku_keycertsign?language=objc)
410    pub static kSecPolicyKU_KeyCertSign: &'static CFString;
411}
412
413extern "C" {
414    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyku_crlsign?language=objc)
415    pub static kSecPolicyKU_CRLSign: &'static CFString;
416}
417
418extern "C" {
419    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyku_encipheronly?language=objc)
420    pub static kSecPolicyKU_EncipherOnly: &'static CFString;
421}
422
423extern "C" {
424    /// [Apple's documentation](https://developer.apple.com/documentation/security/ksecpolicyku_decipheronly?language=objc)
425    pub static kSecPolicyKU_DecipherOnly: &'static CFString;
426}
427
428#[cfg(feature = "SecBase")]
429impl SecPolicy {
430    /// Returns a policy object based on an object identifier for the
431    /// policy type. See the "Policy Constants" section for a list of defined
432    /// policy object identifiers.
433    ///
434    /// Parameter `policyOID`: The OID of the desired policy.
435    ///
436    /// Returns: The returned policy reference, or NULL if the policy could not be
437    /// created.
438    ///
439    /// This function is deprecated in Mac OS X 10.9 and later;
440    /// use SecPolicyCreateWithProperties (or a more specific policy creation
441    /// function) instead.
442    ///
443    /// # Safety
444    ///
445    /// `policy_oid` should be of the correct type.
446    #[doc(alias = "SecPolicyCreateWithOID")]
447    #[cfg(feature = "SecBase")]
448    #[deprecated]
449    #[inline]
450    pub unsafe fn with_oid(policy_oid: &CFType) -> Option<CFRetained<SecPolicy>> {
451        extern "C-unwind" {
452            fn SecPolicyCreateWithOID(policy_oid: &CFType) -> Option<NonNull<SecPolicy>>;
453        }
454        let ret = unsafe { SecPolicyCreateWithOID(policy_oid) };
455        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
456    }
457
458    /// Returns a policy's object identifier.
459    ///
460    /// Parameter `policyRef`: A policy reference.
461    ///
462    /// Parameter `oid`: On return, a pointer to the policy's object identifier.
463    ///
464    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
465    ///
466    /// This function is deprecated in Mac OS X 10.7 and later;
467    /// use SecPolicyCopyProperties instead.
468    ///
469    /// # Safety
470    ///
471    /// `oid` must be a valid pointer.
472    #[doc(alias = "SecPolicyGetOID")]
473    #[cfg(all(feature = "SecAsn1Types", feature = "SecBase"))]
474    #[deprecated]
475    #[inline]
476    pub unsafe fn oid(&self, oid: NonNull<SecAsn1Oid>) -> OSStatus {
477        extern "C-unwind" {
478            fn SecPolicyGetOID(policy_ref: &SecPolicy, oid: NonNull<SecAsn1Oid>) -> OSStatus;
479        }
480        unsafe { SecPolicyGetOID(self, oid) }
481    }
482
483    /// Returns a policy's value.
484    ///
485    /// Parameter `policyRef`: A policy reference.
486    ///
487    /// Parameter `value`: On return, a pointer to the policy's value.
488    ///
489    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
490    ///
491    /// This function is deprecated in Mac OS X 10.7 and later;
492    /// use SecPolicyCopyProperties instead.
493    ///
494    /// # Safety
495    ///
496    /// `value` must be a valid pointer.
497    #[doc(alias = "SecPolicyGetValue")]
498    #[cfg(all(feature = "SecAsn1Types", feature = "SecBase"))]
499    #[deprecated]
500    #[inline]
501    pub unsafe fn value(&self, value: NonNull<SecAsn1Item>) -> OSStatus {
502        extern "C-unwind" {
503            fn SecPolicyGetValue(policy_ref: &SecPolicy, value: NonNull<SecAsn1Item>) -> OSStatus;
504        }
505        unsafe { SecPolicyGetValue(self, value) }
506    }
507
508    /// Sets a policy's value.
509    ///
510    /// Parameter `policyRef`: A policy reference.
511    ///
512    /// Parameter `value`: The value to be set into the policy object, replacing any
513    /// previous value.
514    ///
515    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
516    ///
517    /// This function is deprecated in Mac OS X 10.7 and later. Policy
518    /// instances should be considered read-only; in cases where your code would
519    /// consider changing properties of a policy, it should instead create a new
520    /// policy instance with the desired properties.
521    ///
522    /// # Safety
523    ///
524    /// `value` must be a valid pointer.
525    #[doc(alias = "SecPolicySetValue")]
526    #[cfg(all(feature = "SecAsn1Types", feature = "SecBase"))]
527    #[deprecated]
528    #[inline]
529    pub unsafe fn set_value(&self, value: NonNull<SecAsn1Item>) -> OSStatus {
530        extern "C-unwind" {
531            fn SecPolicySetValue(policy_ref: &SecPolicy, value: NonNull<SecAsn1Item>) -> OSStatus;
532        }
533        unsafe { SecPolicySetValue(self, value) }
534    }
535
536    /// Sets a policy's properties.
537    ///
538    /// Parameter `policyRef`: A policy reference.
539    ///
540    /// Parameter `properties`: A properties dictionary. See "Policy Value Constants"
541    /// for a list of currently defined property keys. This dictionary replaces the
542    /// policy's existing properties, if any. Note that the policy OID (specified
543    /// by kSecPolicyOid) is a read-only property of the policy and cannot be set.
544    ///
545    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
546    ///
547    /// This function is deprecated in Mac OS X 10.9 and later. Policy
548    /// instances should be considered read-only; in cases where your code would
549    /// consider changing properties of a policy, it should instead create a new
550    /// policy instance with the desired properties.
551    ///
552    /// # Safety
553    ///
554    /// `properties` generics must be of the correct type.
555    #[doc(alias = "SecPolicySetProperties")]
556    #[cfg(feature = "SecBase")]
557    #[deprecated]
558    #[inline]
559    pub unsafe fn set_properties(&self, properties: &CFDictionary) -> OSStatus {
560        extern "C-unwind" {
561            fn SecPolicySetProperties(
562                policy_ref: &SecPolicy,
563                properties: &CFDictionary,
564            ) -> OSStatus;
565        }
566        unsafe { SecPolicySetProperties(self, properties) }
567    }
568
569    /// Returns the CSSM trust policy handle for the given policy.
570    ///
571    /// Parameter `policyRef`: A policy reference.
572    ///
573    /// Parameter `tpHandle`: On return, a pointer to a value of type CSSM_TP_HANDLE.
574    ///
575    /// Returns: A result code. See "Security Error Codes" (SecBase.h).
576    ///
577    /// This function is deprecated in Mac OS X 10.7 and later.
578    ///
579    /// # Safety
580    ///
581    /// `tp_handle` must be a valid pointer.
582    #[doc(alias = "SecPolicyGetTPHandle")]
583    #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
584    #[deprecated]
585    #[inline]
586    pub unsafe fn tp_handle(&self, tp_handle: NonNull<CSSM_TP_HANDLE>) -> OSStatus {
587        extern "C-unwind" {
588            fn SecPolicyGetTPHandle(
589                policy_ref: &SecPolicy,
590                tp_handle: NonNull<CSSM_TP_HANDLE>,
591            ) -> OSStatus;
592        }
593        unsafe { SecPolicyGetTPHandle(self, tp_handle) }
594    }
595}
596
597#[cfg(feature = "SecBase")]
598#[deprecated = "renamed to `SecPolicy::properties`"]
599#[inline]
600pub unsafe extern "C-unwind" fn SecPolicyCopyProperties(
601    policy_ref: &SecPolicy,
602) -> Option<CFRetained<CFDictionary>> {
603    extern "C-unwind" {
604        fn SecPolicyCopyProperties(policy_ref: &SecPolicy) -> Option<NonNull<CFDictionary>>;
605    }
606    let ret = unsafe { SecPolicyCopyProperties(policy_ref) };
607    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
608}
609
610#[cfg(feature = "SecBase")]
611#[deprecated = "renamed to `SecPolicy::new_basic_x509`"]
612#[inline]
613pub unsafe extern "C-unwind" fn SecPolicyCreateBasicX509() -> CFRetained<SecPolicy> {
614    extern "C-unwind" {
615        fn SecPolicyCreateBasicX509() -> Option<NonNull<SecPolicy>>;
616    }
617    let ret = unsafe { SecPolicyCreateBasicX509() };
618    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
619    unsafe { CFRetained::from_raw(ret) }
620}
621
622#[cfg(feature = "SecBase")]
623#[deprecated = "renamed to `SecPolicy::new_ssl`"]
624#[inline]
625pub unsafe extern "C-unwind" fn SecPolicyCreateSSL(
626    server: bool,
627    hostname: Option<&CFString>,
628) -> CFRetained<SecPolicy> {
629    extern "C-unwind" {
630        fn SecPolicyCreateSSL(
631            server: Boolean,
632            hostname: Option<&CFString>,
633        ) -> Option<NonNull<SecPolicy>>;
634    }
635    let ret = unsafe { SecPolicyCreateSSL(server as _, hostname) };
636    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
637    unsafe { CFRetained::from_raw(ret) }
638}
639
640#[cfg(feature = "SecBase")]
641#[deprecated = "renamed to `SecPolicy::new_revocation`"]
642#[inline]
643pub unsafe extern "C-unwind" fn SecPolicyCreateRevocation(
644    revocation_flags: CFOptionFlags,
645) -> Option<CFRetained<SecPolicy>> {
646    extern "C-unwind" {
647        fn SecPolicyCreateRevocation(revocation_flags: CFOptionFlags)
648            -> Option<NonNull<SecPolicy>>;
649    }
650    let ret = unsafe { SecPolicyCreateRevocation(revocation_flags) };
651    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
652}
653
654#[cfg(feature = "SecBase")]
655#[deprecated = "renamed to `SecPolicy::with_properties`"]
656#[inline]
657pub unsafe extern "C-unwind" fn SecPolicyCreateWithProperties(
658    policy_identifier: &CFType,
659    properties: Option<&CFDictionary>,
660) -> Option<CFRetained<SecPolicy>> {
661    extern "C-unwind" {
662        fn SecPolicyCreateWithProperties(
663            policy_identifier: &CFType,
664            properties: Option<&CFDictionary>,
665        ) -> Option<NonNull<SecPolicy>>;
666    }
667    let ret = unsafe { SecPolicyCreateWithProperties(policy_identifier, properties) };
668    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
669}
670
671#[cfg(feature = "SecBase")]
672#[deprecated = "renamed to `SecPolicy::with_oid`"]
673#[inline]
674pub unsafe extern "C-unwind" fn SecPolicyCreateWithOID(
675    policy_oid: &CFType,
676) -> Option<CFRetained<SecPolicy>> {
677    extern "C-unwind" {
678        fn SecPolicyCreateWithOID(policy_oid: &CFType) -> Option<NonNull<SecPolicy>>;
679    }
680    let ret = unsafe { SecPolicyCreateWithOID(policy_oid) };
681    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
682}
683
684extern "C-unwind" {
685    #[cfg(all(feature = "SecAsn1Types", feature = "SecBase"))]
686    #[deprecated = "renamed to `SecPolicy::oid`"]
687    pub fn SecPolicyGetOID(policy_ref: &SecPolicy, oid: NonNull<SecAsn1Oid>) -> OSStatus;
688}
689
690extern "C-unwind" {
691    #[cfg(all(feature = "SecAsn1Types", feature = "SecBase"))]
692    #[deprecated = "renamed to `SecPolicy::value`"]
693    pub fn SecPolicyGetValue(policy_ref: &SecPolicy, value: NonNull<SecAsn1Item>) -> OSStatus;
694}
695
696extern "C-unwind" {
697    #[cfg(all(feature = "SecAsn1Types", feature = "SecBase"))]
698    #[deprecated = "renamed to `SecPolicy::set_value`"]
699    pub fn SecPolicySetValue(policy_ref: &SecPolicy, value: NonNull<SecAsn1Item>) -> OSStatus;
700}
701
702extern "C-unwind" {
703    #[cfg(feature = "SecBase")]
704    #[deprecated = "renamed to `SecPolicy::set_properties`"]
705    pub fn SecPolicySetProperties(policy_ref: &SecPolicy, properties: &CFDictionary) -> OSStatus;
706}
707
708extern "C-unwind" {
709    #[cfg(all(feature = "SecBase", feature = "cssmconfig", feature = "cssmtype"))]
710    #[deprecated = "renamed to `SecPolicy::tp_handle`"]
711    pub fn SecPolicyGetTPHandle(
712        policy_ref: &SecPolicy,
713        tp_handle: NonNull<CSSM_TP_HANDLE>,
714    ) -> OSStatus;
715}