objc2_security/generated/
SecProtocolTypes.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use 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/// [Apple's documentation](https://developer.apple.com/documentation/security/sec_trust?language=objc)
14#[repr(C)]
15#[derive(Debug)]
16pub struct sec_trust {
17    inner: [u8; 0],
18    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21#[cfg(feature = "objc2")]
22unsafe impl RefEncode for sec_trust {
23    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("sec_trust", &[]));
24}
25
26/// [Apple's documentation](https://developer.apple.com/documentation/security/sec_trust_t?language=objc)
27pub type sec_trust_t = *mut sec_trust;
28
29/// [Apple's documentation](https://developer.apple.com/documentation/security/sec_identity?language=objc)
30#[repr(C)]
31#[derive(Debug)]
32pub struct sec_identity {
33    inner: [u8; 0],
34    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
35}
36
37#[cfg(feature = "objc2")]
38unsafe impl RefEncode for sec_identity {
39    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("sec_identity", &[]));
40}
41
42/// [Apple's documentation](https://developer.apple.com/documentation/security/sec_identity_t?language=objc)
43pub type sec_identity_t = *mut sec_identity;
44
45/// [Apple's documentation](https://developer.apple.com/documentation/security/sec_certificate?language=objc)
46#[repr(C)]
47#[derive(Debug)]
48pub struct sec_certificate {
49    inner: [u8; 0],
50    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
51}
52
53#[cfg(feature = "objc2")]
54unsafe impl RefEncode for sec_certificate {
55    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("sec_certificate", &[]));
56}
57
58/// [Apple's documentation](https://developer.apple.com/documentation/security/sec_certificate_t?language=objc)
59pub type sec_certificate_t = *mut sec_certificate;
60
61/// Enumerations for the set of supported TLS and DTLS protocol versions.
62///
63/// See also [Apple's documentation](https://developer.apple.com/documentation/security/tls_protocol_version_t?language=objc)
64// NS_ENUM
65#[repr(transparent)]
66#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
67pub struct tls_protocol_version_t(pub u16);
68impl tls_protocol_version_t {
69    #[deprecated = "Use tls_protocol_version_TLSv12 or tls_protocol_version_TLSv13 instead."]
70    #[doc(alias = "tls_protocol_version_TLSv10")]
71    pub const TLSv10: Self = Self(0x0301);
72    #[deprecated = "Use tls_protocol_version_TLSv12 or tls_protocol_version_TLSv13 instead."]
73    #[doc(alias = "tls_protocol_version_TLSv11")]
74    pub const TLSv11: Self = Self(0x0302);
75    #[doc(alias = "tls_protocol_version_TLSv12")]
76    pub const TLSv12: Self = Self(0x0303);
77    #[doc(alias = "tls_protocol_version_TLSv13")]
78    pub const TLSv13: Self = Self(0x0304);
79    #[deprecated = "Use tls_protocol_version_DTLSv12 instead."]
80    #[doc(alias = "tls_protocol_version_DTLSv10")]
81    pub const DTLSv10: Self = Self(0xfeff);
82    #[doc(alias = "tls_protocol_version_DTLSv12")]
83    pub const DTLSv12: Self = Self(0xfefd);
84}
85
86#[cfg(feature = "objc2")]
87unsafe impl Encode for tls_protocol_version_t {
88    const ENCODING: Encoding = u16::ENCODING;
89}
90
91#[cfg(feature = "objc2")]
92unsafe impl RefEncode for tls_protocol_version_t {
93    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
94}
95
96/// Enumerations for the set of supported TLS and DTLS ciphersuites.
97///
98/// See https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
99/// for ciphersuite codepoint allocations and reference RFCs.
100///
101/// See also [Apple's documentation](https://developer.apple.com/documentation/security/tls_ciphersuite_t?language=objc)
102// NS_ENUM
103#[repr(transparent)]
104#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
105pub struct tls_ciphersuite_t(pub u16);
106impl tls_ciphersuite_t {
107    #[deprecated]
108    #[doc(alias = "tls_ciphersuite_RSA_WITH_3DES_EDE_CBC_SHA")]
109    pub const RSA_WITH_3DES_EDE_CBC_SHA: Self = Self(0x000A);
110    #[doc(alias = "tls_ciphersuite_RSA_WITH_AES_128_CBC_SHA")]
111    pub const RSA_WITH_AES_128_CBC_SHA: Self = Self(0x002F);
112    #[doc(alias = "tls_ciphersuite_RSA_WITH_AES_256_CBC_SHA")]
113    pub const RSA_WITH_AES_256_CBC_SHA: Self = Self(0x0035);
114    #[doc(alias = "tls_ciphersuite_RSA_WITH_AES_128_GCM_SHA256")]
115    pub const RSA_WITH_AES_128_GCM_SHA256: Self = Self(0x009C);
116    #[doc(alias = "tls_ciphersuite_RSA_WITH_AES_256_GCM_SHA384")]
117    pub const RSA_WITH_AES_256_GCM_SHA384: Self = Self(0x009D);
118    #[doc(alias = "tls_ciphersuite_RSA_WITH_AES_128_CBC_SHA256")]
119    pub const RSA_WITH_AES_128_CBC_SHA256: Self = Self(0x003C);
120    #[doc(alias = "tls_ciphersuite_RSA_WITH_AES_256_CBC_SHA256")]
121    pub const RSA_WITH_AES_256_CBC_SHA256: Self = Self(0x003D);
122    #[deprecated]
123    #[doc(alias = "tls_ciphersuite_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA")]
124    pub const ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA: Self = Self(0xC008);
125    #[doc(alias = "tls_ciphersuite_ECDHE_ECDSA_WITH_AES_128_CBC_SHA")]
126    pub const ECDHE_ECDSA_WITH_AES_128_CBC_SHA: Self = Self(0xC009);
127    #[doc(alias = "tls_ciphersuite_ECDHE_ECDSA_WITH_AES_256_CBC_SHA")]
128    pub const ECDHE_ECDSA_WITH_AES_256_CBC_SHA: Self = Self(0xC00A);
129    #[deprecated]
130    #[doc(alias = "tls_ciphersuite_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA")]
131    pub const ECDHE_RSA_WITH_3DES_EDE_CBC_SHA: Self = Self(0xC012);
132    #[doc(alias = "tls_ciphersuite_ECDHE_RSA_WITH_AES_128_CBC_SHA")]
133    pub const ECDHE_RSA_WITH_AES_128_CBC_SHA: Self = Self(0xC013);
134    #[doc(alias = "tls_ciphersuite_ECDHE_RSA_WITH_AES_256_CBC_SHA")]
135    pub const ECDHE_RSA_WITH_AES_256_CBC_SHA: Self = Self(0xC014);
136    #[doc(alias = "tls_ciphersuite_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256")]
137    pub const ECDHE_ECDSA_WITH_AES_128_CBC_SHA256: Self = Self(0xC023);
138    #[doc(alias = "tls_ciphersuite_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384")]
139    pub const ECDHE_ECDSA_WITH_AES_256_CBC_SHA384: Self = Self(0xC024);
140    #[doc(alias = "tls_ciphersuite_ECDHE_RSA_WITH_AES_128_CBC_SHA256")]
141    pub const ECDHE_RSA_WITH_AES_128_CBC_SHA256: Self = Self(0xC027);
142    #[doc(alias = "tls_ciphersuite_ECDHE_RSA_WITH_AES_256_CBC_SHA384")]
143    pub const ECDHE_RSA_WITH_AES_256_CBC_SHA384: Self = Self(0xC028);
144    #[doc(alias = "tls_ciphersuite_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256")]
145    pub const ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: Self = Self(0xC02B);
146    #[doc(alias = "tls_ciphersuite_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384")]
147    pub const ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: Self = Self(0xC02C);
148    #[doc(alias = "tls_ciphersuite_ECDHE_RSA_WITH_AES_128_GCM_SHA256")]
149    pub const ECDHE_RSA_WITH_AES_128_GCM_SHA256: Self = Self(0xC02F);
150    #[doc(alias = "tls_ciphersuite_ECDHE_RSA_WITH_AES_256_GCM_SHA384")]
151    pub const ECDHE_RSA_WITH_AES_256_GCM_SHA384: Self = Self(0xC030);
152    #[doc(alias = "tls_ciphersuite_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256")]
153    pub const ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: Self = Self(0xCCA8);
154    #[doc(alias = "tls_ciphersuite_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256")]
155    pub const ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: Self = Self(0xCCA9);
156    #[doc(alias = "tls_ciphersuite_AES_128_GCM_SHA256")]
157    pub const AES_128_GCM_SHA256: Self = Self(0x1301);
158    #[doc(alias = "tls_ciphersuite_AES_256_GCM_SHA384")]
159    pub const AES_256_GCM_SHA384: Self = Self(0x1302);
160    #[doc(alias = "tls_ciphersuite_CHACHA20_POLY1305_SHA256")]
161    pub const CHACHA20_POLY1305_SHA256: Self = Self(0x1303);
162}
163
164#[cfg(feature = "objc2")]
165unsafe impl Encode for tls_ciphersuite_t {
166    const ENCODING: Encoding = u16::ENCODING;
167}
168
169#[cfg(feature = "objc2")]
170unsafe impl RefEncode for tls_ciphersuite_t {
171    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
172}
173
174/// Convenience ciphersuite groups that collate ciphersuites of comparable security
175/// properties into a single alias.
176///
177/// See also [Apple's documentation](https://developer.apple.com/documentation/security/tls_ciphersuite_group_t?language=objc)
178// NS_ENUM
179#[repr(transparent)]
180#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
181pub struct tls_ciphersuite_group_t(pub u16);
182impl tls_ciphersuite_group_t {
183    #[doc(alias = "tls_ciphersuite_group_default")]
184    pub const default: Self = Self(0);
185    #[doc(alias = "tls_ciphersuite_group_compatibility")]
186    pub const compatibility: Self = Self(1);
187    #[doc(alias = "tls_ciphersuite_group_legacy")]
188    pub const legacy: Self = Self(2);
189    #[doc(alias = "tls_ciphersuite_group_ats")]
190    pub const ats: Self = Self(3);
191    #[doc(alias = "tls_ciphersuite_group_ats_compatibility")]
192    pub const ats_compatibility: Self = Self(4);
193}
194
195#[cfg(feature = "objc2")]
196unsafe impl Encode for tls_ciphersuite_group_t {
197    const ENCODING: Encoding = u16::ENCODING;
198}
199
200#[cfg(feature = "objc2")]
201unsafe impl RefEncode for tls_ciphersuite_group_t {
202    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
203}
204
205/// Enumerations for the set of supported TLS and DTLS protocol versions.
206///
207///
208/// Note: This enumeration is deprecated. Use `tls_protocol_version_t` instead.
209///
210/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sslprotocol?language=objc)
211// NS_ENUM
212#[repr(transparent)]
213#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
214pub struct SSLProtocol(pub c_int);
215impl SSLProtocol {
216    #[deprecated]
217    #[doc(alias = "kSSLProtocolUnknown")]
218    pub const SSLProtocolUnknown: Self = Self(0);
219    #[deprecated]
220    #[doc(alias = "kTLSProtocol1")]
221    pub const TLSProtocol1: Self = Self(4);
222    #[deprecated]
223    #[doc(alias = "kTLSProtocol11")]
224    pub const TLSProtocol11: Self = Self(7);
225    #[deprecated]
226    #[doc(alias = "kTLSProtocol12")]
227    pub const TLSProtocol12: Self = Self(8);
228    #[deprecated]
229    #[doc(alias = "kDTLSProtocol1")]
230    pub const DTLSProtocol1: Self = Self(9);
231    #[deprecated]
232    #[doc(alias = "kTLSProtocol13")]
233    pub const TLSProtocol13: Self = Self(10);
234    #[deprecated]
235    #[doc(alias = "kDTLSProtocol12")]
236    pub const DTLSProtocol12: Self = Self(11);
237    #[deprecated]
238    #[doc(alias = "kTLSProtocolMaxSupported")]
239    pub const TLSProtocolMaxSupported: Self = Self(999);
240    #[deprecated]
241    #[doc(alias = "kSSLProtocol2")]
242    pub const SSLProtocol2: Self = Self(1);
243    #[deprecated]
244    #[doc(alias = "kSSLProtocol3")]
245    pub const SSLProtocol3: Self = Self(2);
246    #[deprecated]
247    #[doc(alias = "kSSLProtocol3Only")]
248    pub const SSLProtocol3Only: Self = Self(3);
249    #[deprecated]
250    #[doc(alias = "kTLSProtocol1Only")]
251    pub const TLSProtocol1Only: Self = Self(5);
252    #[deprecated]
253    #[doc(alias = "kSSLProtocolAll")]
254    pub const SSLProtocolAll: Self = Self(6);
255}
256
257#[cfg(feature = "objc2")]
258unsafe impl Encode for SSLProtocol {
259    const ENCODING: Encoding = c_int::ENCODING;
260}
261
262#[cfg(feature = "objc2")]
263unsafe impl RefEncode for SSLProtocol {
264    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
265}
266
267extern "C-unwind" {
268    /// Create an ARC-able `sec_trust_t` instance from a `SecTrustRef`.
269    ///
270    ///
271    /// Parameter `trust`: A `SecTrustRef` instance.
272    ///
273    ///
274    /// Returns: a `sec_trust_t` instance.
275    #[cfg(feature = "SecTrust")]
276    pub fn sec_trust_create(trust: &SecTrust) -> sec_trust_t;
277}
278
279/// Copy a retained reference to the underlying `SecTrustRef` instance.
280///
281///
282/// Parameter `trust`: A `sec_trust_t` instance.
283///
284///
285/// Returns: The underlying `SecTrustRef` instance.
286#[cfg(feature = "SecTrust")]
287#[inline]
288pub unsafe extern "C-unwind" fn sec_trust_copy_ref(trust: sec_trust_t) -> CFRetained<SecTrust> {
289    extern "C-unwind" {
290        fn sec_trust_copy_ref(trust: sec_trust_t) -> Option<NonNull<SecTrust>>;
291    }
292    let ret = unsafe { sec_trust_copy_ref(trust) };
293    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
294    unsafe { CFRetained::from_raw(ret) }
295}
296
297extern "C-unwind" {
298    /// Create an ARC-able `sec_identity_t` instance from a `SecIdentityRef`.
299    ///
300    ///
301    /// Parameter `identity`: A `SecIdentityRef` instance.
302    ///
303    ///
304    /// Returns: a `sec_identity_t` instance.
305    #[cfg(feature = "SecBase")]
306    pub fn sec_identity_create(identity: &SecIdentity) -> sec_identity_t;
307}
308
309extern "C-unwind" {
310    /// Create an ARC-able `sec_identity_t` instance from a `SecIdentityRef` and
311    /// array of SecCertificateRef instances.
312    ///
313    ///
314    /// Parameter `identity`: A `SecIdentityRef` instance.
315    ///
316    ///
317    /// Parameter `certificates`: An array of `SecCertificateRef` instances.
318    ///
319    ///
320    /// Returns: a `sec_identity_t` instance.
321    #[cfg(feature = "SecBase")]
322    pub fn sec_identity_create_with_certificates(
323        identity: &SecIdentity,
324        certificates: &CFArray,
325    ) -> sec_identity_t;
326}
327
328extern "C-unwind" {
329    /// Access the certificates associated with the `sec_identity_t` instance.
330    ///
331    ///
332    /// Parameter `identity`: A `sec_identity_t` instance.
333    ///
334    ///
335    /// Parameter `handler`: A block to invoke one or more times with `sec_certificate_t` instances.
336    ///
337    ///
338    /// Returns: Returns true if the peer certificates were accessible, false otherwise.
339    #[cfg(feature = "block2")]
340    pub fn sec_identity_access_certificates(
341        identity: sec_identity_t,
342        handler: &block2::Block<dyn Fn(sec_certificate_t)>,
343    ) -> bool;
344}
345
346/// Copy a retained reference to the underlying `SecIdentityRef` instance.
347///
348///
349/// Parameter `identity`: A `sec_identity_t` instance.
350///
351///
352/// Returns: The underlying `SecIdentityRef` instance.
353#[cfg(feature = "SecBase")]
354#[inline]
355pub unsafe extern "C-unwind" fn sec_identity_copy_ref(
356    identity: sec_identity_t,
357) -> Option<CFRetained<SecIdentity>> {
358    extern "C-unwind" {
359        fn sec_identity_copy_ref(identity: sec_identity_t) -> Option<NonNull<SecIdentity>>;
360    }
361    let ret = unsafe { sec_identity_copy_ref(identity) };
362    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
363}
364
365/// Copy a retained reference to the underlying `CFArrayRef` container of `SecCertificateRef` types.
366///
367///
368/// Parameter `identity`: A `sec_identity_t` instance.
369///
370///
371/// Returns: The underlying `CFArrayRef` container with `SecCertificateRef` instances.
372#[inline]
373pub unsafe extern "C-unwind" fn sec_identity_copy_certificates_ref(
374    identity: sec_identity_t,
375) -> Option<CFRetained<CFArray>> {
376    extern "C-unwind" {
377        fn sec_identity_copy_certificates_ref(identity: sec_identity_t)
378            -> Option<NonNull<CFArray>>;
379    }
380    let ret = unsafe { sec_identity_copy_certificates_ref(identity) };
381    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
382}
383
384extern "C-unwind" {
385    /// Create an ARC-able `sec_certificate_t` instance from a `SecCertificateRef`.
386    ///
387    ///
388    /// Parameter `certificate`: A `SecCertificateRef` instance.
389    ///
390    ///
391    /// Returns: a `sec_certificate_t` instance.
392    #[cfg(feature = "SecBase")]
393    pub fn sec_certificate_create(certificate: &SecCertificate) -> sec_certificate_t;
394}
395
396/// Copy a retained reference to the underlying `SecCertificateRef` instance.
397///
398///
399/// Parameter `certificate`: A `sec_certificate_t` instance.
400///
401///
402/// Returns: The underlying `SecCertificateRef` instance.
403#[cfg(feature = "SecBase")]
404#[inline]
405pub unsafe extern "C-unwind" fn sec_certificate_copy_ref(
406    certificate: sec_certificate_t,
407) -> CFRetained<SecCertificate> {
408    extern "C-unwind" {
409        fn sec_certificate_copy_ref(
410            certificate: sec_certificate_t,
411        ) -> Option<NonNull<SecCertificate>>;
412    }
413    let ret = unsafe { sec_certificate_copy_ref(certificate) };
414    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
415    unsafe { CFRetained::from_raw(ret) }
416}