objc2_security/generated/
SecProtocolMetadata.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::*;
9
10use crate::*;
11
12/// A `sec_protocol_metadata` instance conatins read-only properties of a connected and configured
13/// security protocol. Clients use this object to read information about a protocol instance. Properties
14/// include, for example, the negotiated TLS version, ciphersuite, and peer certificates.
15///
16/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sec_protocol_metadata?language=objc)
17#[repr(C)]
18#[derive(Debug)]
19pub struct sec_protocol_metadata {
20    inner: [u8; 0],
21    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
22}
23
24#[cfg(feature = "objc2")]
25unsafe impl RefEncode for sec_protocol_metadata {
26    const ENCODING_REF: Encoding =
27        Encoding::Pointer(&Encoding::Struct("sec_protocol_metadata", &[]));
28}
29
30/// A `sec_protocol_metadata` instance conatins read-only properties of a connected and configured
31/// security protocol. Clients use this object to read information about a protocol instance. Properties
32/// include, for example, the negotiated TLS version, ciphersuite, and peer certificates.
33///
34/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sec_protocol_metadata_t?language=objc)
35pub type sec_protocol_metadata_t = *mut sec_protocol_metadata;
36
37impl sec_protocol_metadata {
38    /// Get the application protocol negotiated, e.g., via the TLS ALPN extension.
39    ///
40    ///
41    /// Parameter `metadata`: A `sec_protocol_metadata_t` instance.
42    ///
43    ///
44    /// Returns: A NULL-terminated string carrying the negotiated protocol.
45    ///
46    /// # Safety
47    ///
48    /// `metadata` must be a valid pointer.
49    #[doc(alias = "sec_protocol_metadata_get_negotiated_protocol")]
50    #[deprecated]
51    #[inline]
52    pub unsafe fn negotiated_protocol(metadata: sec_protocol_metadata_t) -> *const c_char {
53        extern "C-unwind" {
54            fn sec_protocol_metadata_get_negotiated_protocol(
55                metadata: sec_protocol_metadata_t,
56            ) -> *const c_char;
57        }
58        unsafe { sec_protocol_metadata_get_negotiated_protocol(metadata) }
59    }
60
61    /// Copy the application protocol negotiated, e.g., via the TLS ALPN extension.
62    /// The caller is expected to `free` the output string when no longer needed.
63    ///
64    ///
65    /// Parameter `metadata`: A `sec_protocol_metadata_t` instance.
66    ///
67    ///
68    /// Returns: A NULL-terminated string carrying the negotiated protocol.
69    ///
70    /// # Safety
71    ///
72    /// `metadata` must be a valid pointer.
73    #[doc(alias = "sec_protocol_metadata_copy_negotiated_protocol")]
74    #[inline]
75    pub unsafe fn copy_negotiated_protocol(metadata: sec_protocol_metadata_t) -> *const c_char {
76        extern "C-unwind" {
77            fn sec_protocol_metadata_copy_negotiated_protocol(
78                metadata: sec_protocol_metadata_t,
79            ) -> *const c_char;
80        }
81        unsafe { sec_protocol_metadata_copy_negotiated_protocol(metadata) }
82    }
83
84    /// Get the negotiated TLS version.
85    ///
86    ///
87    /// Parameter `metadata`: A `sec_protocol_metadata_t` instance.
88    ///
89    ///
90    /// Returns: A `tls_protocol_version_t` value.
91    ///
92    /// # Safety
93    ///
94    /// `metadata` must be a valid pointer.
95    #[doc(alias = "sec_protocol_metadata_get_negotiated_tls_protocol_version")]
96    #[cfg(feature = "SecProtocolTypes")]
97    #[inline]
98    pub unsafe fn negotiated_tls_protocol_version(
99        metadata: sec_protocol_metadata_t,
100    ) -> tls_protocol_version_t {
101        extern "C-unwind" {
102            fn sec_protocol_metadata_get_negotiated_tls_protocol_version(
103                metadata: sec_protocol_metadata_t,
104            ) -> tls_protocol_version_t;
105        }
106        unsafe { sec_protocol_metadata_get_negotiated_tls_protocol_version(metadata) }
107    }
108
109    /// Get the negotiated TLS version.
110    ///
111    ///
112    /// Parameter `metadata`: A `sec_protocol_metadata_t` instance.
113    ///
114    ///
115    /// Returns: A SSLProtocol enum of the TLS version.
116    ///
117    /// # Safety
118    ///
119    /// `metadata` must be a valid pointer.
120    #[doc(alias = "sec_protocol_metadata_get_negotiated_protocol_version")]
121    #[cfg(feature = "SecProtocolTypes")]
122    #[deprecated]
123    #[inline]
124    pub unsafe fn negotiated_protocol_version(metadata: sec_protocol_metadata_t) -> SSLProtocol {
125        extern "C-unwind" {
126            fn sec_protocol_metadata_get_negotiated_protocol_version(
127                metadata: sec_protocol_metadata_t,
128            ) -> SSLProtocol;
129        }
130        unsafe { sec_protocol_metadata_get_negotiated_protocol_version(metadata) }
131    }
132
133    /// Get the negotiated TLS ciphersuite.
134    ///
135    ///
136    /// Parameter `metadata`: A `sec_protocol_metadata_t` instance.
137    ///
138    ///
139    /// Returns: A `tls_ciphersuite_t`.
140    ///
141    /// # Safety
142    ///
143    /// `metadata` must be a valid pointer.
144    #[doc(alias = "sec_protocol_metadata_get_negotiated_tls_ciphersuite")]
145    #[cfg(feature = "SecProtocolTypes")]
146    #[inline]
147    pub unsafe fn negotiated_tls_ciphersuite(
148        metadata: sec_protocol_metadata_t,
149    ) -> tls_ciphersuite_t {
150        extern "C-unwind" {
151            fn sec_protocol_metadata_get_negotiated_tls_ciphersuite(
152                metadata: sec_protocol_metadata_t,
153            ) -> tls_ciphersuite_t;
154        }
155        unsafe { sec_protocol_metadata_get_negotiated_tls_ciphersuite(metadata) }
156    }
157
158    /// Get the negotiated TLS ciphersuite.
159    ///
160    ///
161    /// Parameter `metadata`: A `sec_protocol_metadata_t` instance.
162    ///
163    ///
164    /// Returns: A SSLCipherSuite.
165    ///
166    /// # Safety
167    ///
168    /// `metadata` must be a valid pointer.
169    #[doc(alias = "sec_protocol_metadata_get_negotiated_ciphersuite")]
170    #[cfg(feature = "CipherSuite")]
171    #[deprecated]
172    #[inline]
173    pub unsafe fn negotiated_ciphersuite(metadata: sec_protocol_metadata_t) -> SSLCipherSuite {
174        extern "C-unwind" {
175            fn sec_protocol_metadata_get_negotiated_ciphersuite(
176                metadata: sec_protocol_metadata_t,
177            ) -> SSLCipherSuite;
178        }
179        unsafe { sec_protocol_metadata_get_negotiated_ciphersuite(metadata) }
180    }
181
182    /// Determine if early data was accepted by the peer.
183    ///
184    ///
185    /// Parameter `metadata`: A `sec_protocol_metadata_t` instance.
186    ///
187    ///
188    /// Returns: A bool indicating if early data was accepted.
189    ///
190    /// # Safety
191    ///
192    /// `metadata` must be a valid pointer.
193    #[doc(alias = "sec_protocol_metadata_get_early_data_accepted")]
194    #[inline]
195    pub unsafe fn early_data_accepted(metadata: sec_protocol_metadata_t) -> bool {
196        extern "C-unwind" {
197            fn sec_protocol_metadata_get_early_data_accepted(
198                metadata: sec_protocol_metadata_t,
199            ) -> bool;
200        }
201        unsafe { sec_protocol_metadata_get_early_data_accepted(metadata) }
202    }
203
204    /// Get the certificate chain of the protocol instance peer.
205    ///
206    ///
207    /// Parameter `metadata`: A `sec_protocol_metadata_t` instance.
208    ///
209    ///
210    /// Parameter `handler`: A block to invoke one or more times with sec_certificate_t objects
211    ///
212    ///
213    /// Returns: Returns true if the peer certificates were accessible, false otherwise.
214    ///
215    /// # Safety
216    ///
217    /// `metadata` must be a valid pointer.
218    #[doc(alias = "sec_protocol_metadata_access_peer_certificate_chain")]
219    #[cfg(all(feature = "SecProtocolTypes", feature = "block2"))]
220    #[inline]
221    pub unsafe fn access_peer_certificate_chain(
222        metadata: sec_protocol_metadata_t,
223        handler: &block2::DynBlock<dyn Fn(sec_certificate_t)>,
224    ) -> bool {
225        extern "C-unwind" {
226            fn sec_protocol_metadata_access_peer_certificate_chain(
227                metadata: sec_protocol_metadata_t,
228                handler: &block2::DynBlock<dyn Fn(sec_certificate_t)>,
229            ) -> bool;
230        }
231        unsafe { sec_protocol_metadata_access_peer_certificate_chain(metadata, handler) }
232    }
233
234    /// Get the signature algorithms supported by the peer. Clients may call this
235    /// in response to a challenge block.
236    ///
237    ///
238    /// Parameter `metadata`: A `sec_protocol_metadata_t` instance.
239    ///
240    ///
241    /// Parameter `handler`: A block to invoke one or more times with OCSP data
242    ///
243    ///
244    /// Returns: Returns true if the supported signature list was accessible, false otherwise.
245    ///
246    /// # Safety
247    ///
248    /// `metadata` must be a valid pointer.
249    #[doc(alias = "sec_protocol_metadata_access_supported_signature_algorithms")]
250    #[cfg(feature = "block2")]
251    #[inline]
252    pub unsafe fn access_supported_signature_algorithms(
253        metadata: sec_protocol_metadata_t,
254        handler: &block2::DynBlock<dyn Fn(u16)>,
255    ) -> bool {
256        extern "C-unwind" {
257            fn sec_protocol_metadata_access_supported_signature_algorithms(
258                metadata: sec_protocol_metadata_t,
259                handler: &block2::DynBlock<dyn Fn(u16)>,
260            ) -> bool;
261        }
262        unsafe { sec_protocol_metadata_access_supported_signature_algorithms(metadata, handler) }
263    }
264
265    /// Obtain the server name offered by a client or server during
266    /// connection establishmet. This is the value commonly carried
267    /// in the TLS SNI extesion.
268    ///
269    ///
270    /// Parameter `metadata`: A `sec_protocol_metadata_t` instance.
271    ///
272    ///
273    /// Returns: Returns A NULL-terminated string carrying the server name, or NULL
274    /// if none was provided.
275    ///
276    /// # Safety
277    ///
278    /// `metadata` must be a valid pointer.
279    #[doc(alias = "sec_protocol_metadata_get_server_name")]
280    #[deprecated]
281    #[inline]
282    pub unsafe fn server_name(metadata: sec_protocol_metadata_t) -> *const c_char {
283        extern "C-unwind" {
284            fn sec_protocol_metadata_get_server_name(
285                metadata: sec_protocol_metadata_t,
286            ) -> *const c_char;
287        }
288        unsafe { sec_protocol_metadata_get_server_name(metadata) }
289    }
290
291    /// Obtain a copy of the server name offered by a client or server during
292    /// connection establishmet. This is the value commonly carried
293    /// in the TLS SNI extesion. The caller is expected to `free` the output
294    /// string when it is no longer needed.
295    ///
296    ///
297    /// Parameter `metadata`: A `sec_protocol_metadata_t` instance.
298    ///
299    ///
300    /// Returns: Returns A NULL-terminated string carrying the server name, or NULL
301    /// if none was provided.
302    ///
303    /// # Safety
304    ///
305    /// `metadata` must be a valid pointer.
306    #[doc(alias = "sec_protocol_metadata_copy_server_name")]
307    #[inline]
308    pub unsafe fn copy_server_name(metadata: sec_protocol_metadata_t) -> *const c_char {
309        extern "C-unwind" {
310            fn sec_protocol_metadata_copy_server_name(
311                metadata: sec_protocol_metadata_t,
312            ) -> *const c_char;
313        }
314        unsafe { sec_protocol_metadata_copy_server_name(metadata) }
315    }
316
317    /// Compare peer information for two `sec_protocol_metadata` instances.
318    /// This comparison does not include protocol configuration options, e.g., ciphersuites.
319    ///
320    ///
321    /// Parameter `metadataA`: A `sec_protocol_metadata_t` instance.
322    ///
323    ///
324    /// Parameter `metadataB`: A `sec_protocol_metadata_t` instance.
325    ///
326    ///
327    /// Returns: Returns true if both metadata values refer to the same peer, and false otherwise.
328    ///
329    /// # Safety
330    ///
331    /// - `metadata_a` must be a valid pointer.
332    /// - `metadata_b` must be a valid pointer.
333    #[doc(alias = "sec_protocol_metadata_peers_are_equal")]
334    #[inline]
335    pub unsafe fn peers_are_equal(
336        metadata_a: sec_protocol_metadata_t,
337        metadata_b: sec_protocol_metadata_t,
338    ) -> bool {
339        extern "C-unwind" {
340            fn sec_protocol_metadata_peers_are_equal(
341                metadata_a: sec_protocol_metadata_t,
342                metadata_b: sec_protocol_metadata_t,
343            ) -> bool;
344        }
345        unsafe { sec_protocol_metadata_peers_are_equal(metadata_a, metadata_b) }
346    }
347
348    /// Compare challenge-relevant information for two `sec_protocol_metadata` instances.
349    ///
350    /// This comparison includes all information relevant to a challenge request, including:
351    /// distinguished names, signature algorithms, and supported certificate types.
352    /// See Section 7.4.4 of RFC5246 for more details.
353    ///
354    ///
355    /// Parameter `metadataA`: A `sec_protocol_metadata_t` instance.
356    ///
357    ///
358    /// Parameter `metadataB`: A `sec_protocol_metadata_t` instance.
359    ///
360    ///
361    /// Returns: Returns true if both metadata values have the same challenge parameters.
362    ///
363    /// # Safety
364    ///
365    /// - `metadata_a` must be a valid pointer.
366    /// - `metadata_b` must be a valid pointer.
367    #[doc(alias = "sec_protocol_metadata_challenge_parameters_are_equal")]
368    #[inline]
369    pub unsafe fn challenge_parameters_are_equal(
370        metadata_a: sec_protocol_metadata_t,
371        metadata_b: sec_protocol_metadata_t,
372    ) -> bool {
373        extern "C-unwind" {
374            fn sec_protocol_metadata_challenge_parameters_are_equal(
375                metadata_a: sec_protocol_metadata_t,
376                metadata_b: sec_protocol_metadata_t,
377            ) -> bool;
378        }
379        unsafe { sec_protocol_metadata_challenge_parameters_are_equal(metadata_a, metadata_b) }
380    }
381}
382
383extern "C-unwind" {
384    #[deprecated = "renamed to `sec_protocol_metadata::negotiated_protocol`"]
385    pub fn sec_protocol_metadata_get_negotiated_protocol(
386        metadata: sec_protocol_metadata_t,
387    ) -> *const c_char;
388}
389
390extern "C-unwind" {
391    #[deprecated = "renamed to `sec_protocol_metadata::copy_negotiated_protocol`"]
392    pub fn sec_protocol_metadata_copy_negotiated_protocol(
393        metadata: sec_protocol_metadata_t,
394    ) -> *const c_char;
395}
396
397extern "C-unwind" {
398    #[cfg(feature = "SecProtocolTypes")]
399    #[deprecated = "renamed to `sec_protocol_metadata::negotiated_tls_protocol_version`"]
400    pub fn sec_protocol_metadata_get_negotiated_tls_protocol_version(
401        metadata: sec_protocol_metadata_t,
402    ) -> tls_protocol_version_t;
403}
404
405extern "C-unwind" {
406    #[cfg(feature = "SecProtocolTypes")]
407    #[deprecated = "renamed to `sec_protocol_metadata::negotiated_protocol_version`"]
408    pub fn sec_protocol_metadata_get_negotiated_protocol_version(
409        metadata: sec_protocol_metadata_t,
410    ) -> SSLProtocol;
411}
412
413extern "C-unwind" {
414    #[cfg(feature = "SecProtocolTypes")]
415    #[deprecated = "renamed to `sec_protocol_metadata::negotiated_tls_ciphersuite`"]
416    pub fn sec_protocol_metadata_get_negotiated_tls_ciphersuite(
417        metadata: sec_protocol_metadata_t,
418    ) -> tls_ciphersuite_t;
419}
420
421extern "C-unwind" {
422    #[cfg(feature = "CipherSuite")]
423    #[deprecated = "renamed to `sec_protocol_metadata::negotiated_ciphersuite`"]
424    pub fn sec_protocol_metadata_get_negotiated_ciphersuite(
425        metadata: sec_protocol_metadata_t,
426    ) -> SSLCipherSuite;
427}
428
429extern "C-unwind" {
430    #[deprecated = "renamed to `sec_protocol_metadata::early_data_accepted`"]
431    pub fn sec_protocol_metadata_get_early_data_accepted(metadata: sec_protocol_metadata_t)
432        -> bool;
433}
434
435extern "C-unwind" {
436    #[cfg(all(feature = "SecProtocolTypes", feature = "block2"))]
437    #[deprecated = "renamed to `sec_protocol_metadata::access_peer_certificate_chain`"]
438    pub fn sec_protocol_metadata_access_peer_certificate_chain(
439        metadata: sec_protocol_metadata_t,
440        handler: &block2::DynBlock<dyn Fn(sec_certificate_t)>,
441    ) -> bool;
442}
443
444extern "C-unwind" {
445    #[cfg(feature = "block2")]
446    #[deprecated = "renamed to `sec_protocol_metadata::access_supported_signature_algorithms`"]
447    pub fn sec_protocol_metadata_access_supported_signature_algorithms(
448        metadata: sec_protocol_metadata_t,
449        handler: &block2::DynBlock<dyn Fn(u16)>,
450    ) -> bool;
451}
452
453extern "C-unwind" {
454    #[deprecated = "renamed to `sec_protocol_metadata::server_name`"]
455    pub fn sec_protocol_metadata_get_server_name(
456        metadata: sec_protocol_metadata_t,
457    ) -> *const c_char;
458}
459
460extern "C-unwind" {
461    #[deprecated = "renamed to `sec_protocol_metadata::copy_server_name`"]
462    pub fn sec_protocol_metadata_copy_server_name(
463        metadata: sec_protocol_metadata_t,
464    ) -> *const c_char;
465}
466
467extern "C-unwind" {
468    #[deprecated = "renamed to `sec_protocol_metadata::peers_are_equal`"]
469    pub fn sec_protocol_metadata_peers_are_equal(
470        metadata_a: sec_protocol_metadata_t,
471        metadata_b: sec_protocol_metadata_t,
472    ) -> bool;
473}
474
475extern "C-unwind" {
476    #[deprecated = "renamed to `sec_protocol_metadata::challenge_parameters_are_equal`"]
477    pub fn sec_protocol_metadata_challenge_parameters_are_equal(
478        metadata_a: sec_protocol_metadata_t,
479        metadata_b: sec_protocol_metadata_t,
480    ) -> bool;
481}