objc2_security/generated/
SecureDownload.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};
6#[cfg(feature = "objc2")]
7use objc2::__framework_prelude::*;
8use objc2_core_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/security/opaquesecuredownload?language=objc)
13#[repr(C)]
14#[derive(Debug)]
15pub struct OpaqueSecureDownload {
16    inner: [u8; 0],
17    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
18}
19
20#[cfg(feature = "objc2")]
21unsafe impl RefEncode for OpaqueSecureDownload {
22    const ENCODING_REF: Encoding =
23        Encoding::Pointer(&Encoding::Struct("OpaqueSecureDownload", &[]));
24}
25
26/// [Apple's documentation](https://developer.apple.com/documentation/security/securedownloadref?language=objc)
27pub type SecureDownloadRef = *mut OpaqueSecureDownload;
28
29/// [Apple's documentation](https://developer.apple.com/documentation/security/errsecuredownloadinvalidticket?language=objc)
30pub const errSecureDownloadInvalidTicket: c_int = -20052;
31/// [Apple's documentation](https://developer.apple.com/documentation/security/errsecuredownloadinvaliddownload?language=objc)
32pub const errSecureDownloadInvalidDownload: c_int = -20053;
33
34/// This type is used to indicate whether or not a
35/// signer should be evaluated.
36///
37/// See also [Apple's documentation](https://developer.apple.com/documentation/security/securedownloadtrustcallbackresult?language=objc)
38#[repr(transparent)]
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
40pub struct SecureDownloadTrustCallbackResult(pub c_uint);
41impl SecureDownloadTrustCallbackResult {
42    #[doc(alias = "kSecureDownloadDoNotEvaluateSigner")]
43    pub const DoNotEvaluateSigner: Self = Self(0);
44    #[doc(alias = "kSecureDownloadEvaluateSigner")]
45    pub const EvaluateSigner: Self = Self(1);
46    #[doc(alias = "kSecureDownloadFailEvaluation")]
47    pub const FailEvaluation: Self = Self(2);
48}
49
50#[cfg(feature = "objc2")]
51unsafe impl Encode for SecureDownloadTrustCallbackResult {
52    const ENCODING: Encoding = c_uint::ENCODING;
53}
54
55#[cfg(feature = "objc2")]
56unsafe impl RefEncode for SecureDownloadTrustCallbackResult {
57    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
58}
59
60/// This callback is used to determine whether trust for a particular
61/// signer should be evaluated.
62///
63/// Parameter `trustRef`: The trustRef for this evaluation
64///
65/// Parameter `setupContext`: user defined.
66///
67/// Returns: A SecureDownloadTrustCallbackResult (see).
68///
69/// See also [Apple's documentation](https://developer.apple.com/documentation/security/securedownloadtrustsetupcallback?language=objc)
70#[deprecated = "SecureDownload is not supported"]
71#[cfg(feature = "SecTrust")]
72pub type SecureDownloadTrustSetupCallback = Option<
73    unsafe extern "C-unwind" fn(*mut SecTrust, *mut c_void) -> SecureDownloadTrustCallbackResult,
74>;
75
76/// This callback is used called after trust has been evaluated.
77///
78/// Parameter `trustRef`: The trustRef for this evaluation
79///
80/// Parameter `result`: The result of the evaluation (See the SecTrust documentation).
81///
82/// Parameter `evaluateContext`: user defined.
83///
84/// Returns: A SecTrustResultType.  Return the value passed in result if you
85/// do not want to change the evaluation result.
86///
87/// See also [Apple's documentation](https://developer.apple.com/documentation/security/securedownloadtrustevaluatecallback?language=objc)
88#[deprecated = "SecureDownload is not supported"]
89#[cfg(feature = "SecTrust")]
90pub type SecureDownloadTrustEvaluateCallback = Option<
91    unsafe extern "C-unwind" fn(
92        *mut SecTrust,
93        SecTrustResultType,
94        *mut c_void,
95    ) -> SecTrustResultType,
96>;
97
98extern "C-unwind" {
99    /// Create a SecureDownloadRef for use during the Secure Download process.
100    ///
101    /// Parameter `ticket`: The download ticket.
102    ///
103    /// Parameter `setup`: Called before trust is verified for each signer of the ticket.
104    /// This allows the user to modify the SecTrustRef if needed
105    /// (see the SecTrust documentation).  Returns a SecureDownloadTrustCallbackResult (see).
106    ///
107    /// Parameter `setupContext`: User defined.  Passed as a parameter to the setupCallback.
108    ///
109    /// Parameter `evaluate`: Called after SecTrustEvaluate has been called for a
110    /// signer if the result was not trusted. This allows
111    /// the developer to query the user as to whether or not
112    /// to trust the signer.  Returns a SecTrustResultType
113    ///
114    /// Parameter `evaluateContext`: User defined.  Passed as a parameter to the evaluate callback.
115    ///
116    /// Parameter `downloadRef`: The returned reference.
117    ///
118    /// Returns: Returns errSecureDownloadInvalidTicket if the ticket was invalid.  Otherwise
119    /// see "Security Error Codes" (SecBase.h).
120    /// .
121    ///
122    /// # Safety
123    ///
124    /// - `ticket` might not allow `None`.
125    /// - `setup` must be implemented correctly.
126    /// - `setup_context` must be a valid pointer.
127    /// - `evaluate` must be implemented correctly.
128    /// - `evaluate_context` must be a valid pointer.
129    /// - `download_ref` must be a valid pointer.
130    #[cfg(feature = "SecTrust")]
131    #[deprecated = "SecureDownload is not supported"]
132    pub fn SecureDownloadCreateWithTicket(
133        ticket: Option<&CFData>,
134        setup: SecureDownloadTrustSetupCallback,
135        setup_context: *mut c_void,
136        evaluate: SecureDownloadTrustEvaluateCallback,
137        evaluate_context: *mut c_void,
138        download_ref: *mut SecureDownloadRef,
139    ) -> OSStatus;
140}
141
142extern "C-unwind" {
143    /// Return a list of URL's from which the data can be downloaded.  The first
144    /// URL in the list is the preferred download location.  The other URL's are
145    /// backup locations in case earlier locations in the list could not be
146    /// accessed.
147    ///
148    /// Parameter `downloadRef`: A SecureDownloadRef instance.
149    ///
150    /// Parameter `urls`: On return, the list of URL's to download.  Format is a CFArray of CFURL's.
151    ///
152    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
153    ///
154    /// # Safety
155    ///
156    /// - `download_ref` must be a valid pointer.
157    /// - `urls` must be a valid pointer.
158    #[deprecated = "SecureDownload is not supported"]
159    pub fn SecureDownloadCopyURLs(
160        download_ref: SecureDownloadRef,
161        urls: *mut *const CFArray,
162    ) -> OSStatus;
163}
164
165extern "C-unwind" {
166    /// Return the printable name of this download ticket.
167    ///
168    /// Parameter `downloadRef`: A SecureDownloadRef instance.
169    ///
170    /// Parameter `name`: On output, the download name.
171    ///
172    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
173    ///
174    /// # Safety
175    ///
176    /// - `download_ref` must be a valid pointer.
177    /// - `name` must be a valid pointer.
178    #[deprecated = "SecureDownload is not supported"]
179    pub fn SecureDownloadCopyName(
180        download_ref: SecureDownloadRef,
181        name: *mut *const CFString,
182    ) -> OSStatus;
183}
184
185extern "C-unwind" {
186    /// Return the date the downlooad ticket was created.
187    ///
188    /// Parameter `downloadRef`: A SecureDownloadRef instance.
189    ///
190    /// Returns: A result code.
191    ///
192    /// # Safety
193    ///
194    /// - `download_ref` must be a valid pointer.
195    /// - `date` must be a valid pointer.
196    #[deprecated = "SecureDownload is not supported"]
197    pub fn SecureDownloadCopyCreationDate(
198        download_ref: SecureDownloadRef,
199        date: *mut *const CFDate,
200    ) -> OSStatus;
201}
202
203extern "C-unwind" {
204    /// Return the size of the expected download.
205    ///
206    /// Parameter `downloadRef`: A SecureDownloadRef instance.
207    ///
208    /// Parameter `downloadSize`: On output, the size of the download.
209    ///
210    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
211    ///
212    /// # Safety
213    ///
214    /// - `download_ref` must be a valid pointer.
215    /// - `download_size` must be a valid pointer.
216    #[deprecated = "SecureDownload is not supported"]
217    pub fn SecureDownloadGetDownloadSize(
218        download_ref: SecureDownloadRef,
219        download_size: *mut i64,
220    ) -> OSStatus;
221}
222
223extern "C-unwind" {
224    /// Check data received during Secure Download for validity.
225    /// Call this function each time data is received.
226    ///
227    /// Parameter `downloadRef`: A SecureDownloadRef instance.
228    ///
229    /// Parameter `data`: The data to check.
230    ///
231    /// Returns: Returns errSecureDownloadInvalidDownload if data is invalid.  Otherwise
232    /// see "Security Error Codes" (SecBase.h).
233    ///
234    /// # Safety
235    ///
236    /// - `download_ref` must be a valid pointer.
237    /// - `data` might not allow `None`.
238    #[deprecated = "SecureDownload is not supported"]
239    pub fn SecureDownloadUpdateWithData(
240        download_ref: SecureDownloadRef,
241        data: Option<&CFData>,
242    ) -> OSStatus;
243}
244
245extern "C-unwind" {
246    /// Concludes the secure download process.  Call this after all data has been received.
247    ///
248    /// Parameter `downloadRef`: A SecureDownloadRef instance.
249    ///
250    /// Returns: Returns errSecureDownloadInvalidDownload if data is invalid.  Otherwise
251    /// see "Security Error Codes" (SecBase.h).
252    ///
253    /// # Safety
254    ///
255    /// `download_ref` must be a valid pointer.
256    #[deprecated = "SecureDownload is not supported"]
257    pub fn SecureDownloadFinished(download_ref: SecureDownloadRef) -> OSStatus;
258}
259
260extern "C-unwind" {
261    /// Releases a SecureDownloadRef.
262    ///
263    /// Parameter `downloadRef`: The SecureDownloadRef to release.
264    ///
265    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
266    ///
267    /// # Safety
268    ///
269    /// `download_ref` must be a valid pointer.
270    #[deprecated = "SecureDownload is not supported"]
271    pub fn SecureDownloadRelease(download_ref: SecureDownloadRef) -> OSStatus;
272}
273
274extern "C-unwind" {
275    /// Copies the ticket location from an x-securedownload URL.
276    ///
277    /// Parameter `url`: The x-securedownload URL.
278    ///
279    /// Parameter `ticketLocation`: On exit, the URL of the ticket.
280    ///
281    /// Returns: A result code.  See "Security Error Codes" (SecBase.h).
282    ///
283    /// # Safety
284    ///
285    /// - `url` might not allow `None`.
286    /// - `ticket_location` must be a valid pointer.
287    #[deprecated = "SecureDownload is not supported"]
288    pub fn SecureDownloadCopyTicketLocation(
289        url: Option<&CFURL>,
290        ticket_location: *mut *const CFURL,
291    ) -> OSStatus;
292}