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