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
//! 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};
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/security/opaquesecuredownload?language=objc)
#[repr(C)]
#[derive(Debug)]
pub struct OpaqueSecureDownload {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for OpaqueSecureDownload {
const ENCODING_REF: Encoding =
Encoding::Pointer(&Encoding::Struct("OpaqueSecureDownload", &[]));
}
/// [Apple's documentation](https://developer.apple.com/documentation/security/securedownloadref?language=objc)
pub type SecureDownloadRef = *mut OpaqueSecureDownload;
/// [Apple's documentation](https://developer.apple.com/documentation/security/errsecuredownloadinvalidticket?language=objc)
pub const errSecureDownloadInvalidTicket: c_int = -20052;
/// [Apple's documentation](https://developer.apple.com/documentation/security/errsecuredownloadinvaliddownload?language=objc)
pub const errSecureDownloadInvalidDownload: c_int = -20053;
/// This type is used to indicate whether or not a
/// signer should be evaluated.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/securedownloadtrustcallbackresult?language=objc)
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SecureDownloadTrustCallbackResult(pub c_uint);
impl SecureDownloadTrustCallbackResult {
#[doc(alias = "kSecureDownloadDoNotEvaluateSigner")]
pub const DoNotEvaluateSigner: Self = Self(0);
#[doc(alias = "kSecureDownloadEvaluateSigner")]
pub const EvaluateSigner: Self = Self(1);
#[doc(alias = "kSecureDownloadFailEvaluation")]
pub const FailEvaluation: Self = Self(2);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for SecureDownloadTrustCallbackResult {
const ENCODING: Encoding = c_uint::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for SecureDownloadTrustCallbackResult {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// This callback is used to determine whether trust for a particular
/// signer should be evaluated.
///
/// Parameter `trustRef`: The trustRef for this evaluation
///
/// Parameter `setupContext`: user defined.
///
/// Returns: A SecureDownloadTrustCallbackResult (see).
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/securedownloadtrustsetupcallback?language=objc)
#[deprecated = "SecureDownload is not supported"]
#[cfg(feature = "SecTrust")]
pub type SecureDownloadTrustSetupCallback = Option<
unsafe extern "C-unwind" fn(*mut SecTrust, *mut c_void) -> SecureDownloadTrustCallbackResult,
>;
/// This callback is used called after trust has been evaluated.
///
/// Parameter `trustRef`: The trustRef for this evaluation
///
/// Parameter `result`: The result of the evaluation (See the SecTrust documentation).
///
/// Parameter `evaluateContext`: user defined.
///
/// Returns: A SecTrustResultType. Return the value passed in result if you
/// do not want to change the evaluation result.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/securedownloadtrustevaluatecallback?language=objc)
#[deprecated = "SecureDownload is not supported"]
#[cfg(feature = "SecTrust")]
pub type SecureDownloadTrustEvaluateCallback = Option<
unsafe extern "C-unwind" fn(
*mut SecTrust,
SecTrustResultType,
*mut c_void,
) -> SecTrustResultType,
>;
extern "C-unwind" {
/// Create a SecureDownloadRef for use during the Secure Download process.
///
/// Parameter `ticket`: The download ticket.
///
/// Parameter `setup`: Called before trust is verified for each signer of the ticket.
/// This allows the user to modify the SecTrustRef if needed
/// (see the SecTrust documentation). Returns a SecureDownloadTrustCallbackResult (see).
///
/// Parameter `setupContext`: User defined. Passed as a parameter to the setupCallback.
///
/// Parameter `evaluate`: Called after SecTrustEvaluate has been called for a
/// signer if the result was not trusted. This allows
/// the developer to query the user as to whether or not
/// to trust the signer. Returns a SecTrustResultType
///
/// Parameter `evaluateContext`: User defined. Passed as a parameter to the evaluate callback.
///
/// Parameter `downloadRef`: The returned reference.
///
/// Returns: Returns errSecureDownloadInvalidTicket if the ticket was invalid. Otherwise
/// see "Security Error Codes" (SecBase.h).
/// .
///
/// # Safety
///
/// - `ticket` might not allow `None`.
/// - `setup` must be implemented correctly.
/// - `setup_context` must be a valid pointer.
/// - `evaluate` must be implemented correctly.
/// - `evaluate_context` must be a valid pointer.
/// - `download_ref` must be a valid pointer.
#[cfg(feature = "SecTrust")]
#[deprecated = "SecureDownload is not supported"]
pub fn SecureDownloadCreateWithTicket(
ticket: Option<&CFData>,
setup: SecureDownloadTrustSetupCallback,
setup_context: *mut c_void,
evaluate: SecureDownloadTrustEvaluateCallback,
evaluate_context: *mut c_void,
download_ref: *mut SecureDownloadRef,
) -> OSStatus;
}
extern "C-unwind" {
/// Return a list of URL's from which the data can be downloaded. The first
/// URL in the list is the preferred download location. The other URL's are
/// backup locations in case earlier locations in the list could not be
/// accessed.
///
/// Parameter `downloadRef`: A SecureDownloadRef instance.
///
/// Parameter `urls`: On return, the list of URL's to download. Format is a CFArray of CFURL's.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// - `download_ref` must be a valid pointer.
/// - `urls` must be a valid pointer.
#[deprecated = "SecureDownload is not supported"]
pub fn SecureDownloadCopyURLs(
download_ref: SecureDownloadRef,
urls: *mut *const CFArray,
) -> OSStatus;
}
extern "C-unwind" {
/// Return the printable name of this download ticket.
///
/// Parameter `downloadRef`: A SecureDownloadRef instance.
///
/// Parameter `name`: On output, the download name.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// - `download_ref` must be a valid pointer.
/// - `name` must be a valid pointer.
#[deprecated = "SecureDownload is not supported"]
pub fn SecureDownloadCopyName(
download_ref: SecureDownloadRef,
name: *mut *const CFString,
) -> OSStatus;
}
extern "C-unwind" {
/// Return the date the downlooad ticket was created.
///
/// Parameter `downloadRef`: A SecureDownloadRef instance.
///
/// Returns: A result code.
///
/// # Safety
///
/// - `download_ref` must be a valid pointer.
/// - `date` must be a valid pointer.
#[deprecated = "SecureDownload is not supported"]
pub fn SecureDownloadCopyCreationDate(
download_ref: SecureDownloadRef,
date: *mut *const CFDate,
) -> OSStatus;
}
extern "C-unwind" {
/// Return the size of the expected download.
///
/// Parameter `downloadRef`: A SecureDownloadRef instance.
///
/// Parameter `downloadSize`: On output, the size of the download.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// - `download_ref` must be a valid pointer.
/// - `download_size` must be a valid pointer.
#[deprecated = "SecureDownload is not supported"]
pub fn SecureDownloadGetDownloadSize(
download_ref: SecureDownloadRef,
download_size: *mut i64,
) -> OSStatus;
}
extern "C-unwind" {
/// Check data received during Secure Download for validity.
/// Call this function each time data is received.
///
/// Parameter `downloadRef`: A SecureDownloadRef instance.
///
/// Parameter `data`: The data to check.
///
/// Returns: Returns errSecureDownloadInvalidDownload if data is invalid. Otherwise
/// see "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// - `download_ref` must be a valid pointer.
/// - `data` might not allow `None`.
#[deprecated = "SecureDownload is not supported"]
pub fn SecureDownloadUpdateWithData(
download_ref: SecureDownloadRef,
data: Option<&CFData>,
) -> OSStatus;
}
extern "C-unwind" {
/// Concludes the secure download process. Call this after all data has been received.
///
/// Parameter `downloadRef`: A SecureDownloadRef instance.
///
/// Returns: Returns errSecureDownloadInvalidDownload if data is invalid. Otherwise
/// see "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// `download_ref` must be a valid pointer.
#[deprecated = "SecureDownload is not supported"]
pub fn SecureDownloadFinished(download_ref: SecureDownloadRef) -> OSStatus;
}
extern "C-unwind" {
/// Releases a SecureDownloadRef.
///
/// Parameter `downloadRef`: The SecureDownloadRef to release.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// `download_ref` must be a valid pointer.
#[deprecated = "SecureDownload is not supported"]
pub fn SecureDownloadRelease(download_ref: SecureDownloadRef) -> OSStatus;
}
extern "C-unwind" {
/// Copies the ticket location from an x-securedownload URL.
///
/// Parameter `url`: The x-securedownload URL.
///
/// Parameter `ticketLocation`: On exit, the URL of the ticket.
///
/// Returns: A result code. See "Security Error Codes" (SecBase.h).
///
/// # Safety
///
/// - `url` might not allow `None`.
/// - `ticket_location` must be a valid pointer.
#[deprecated = "SecureDownload is not supported"]
pub fn SecureDownloadCopyTicketLocation(
url: Option<&CFURL>,
ticket_location: *mut *const CFURL,
) -> OSStatus;
}