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#[cfg(feature = "SecTrust")]
71pub type SecureDownloadTrustSetupCallback = Option<
72 unsafe extern "C-unwind" fn(*mut SecTrust, *mut c_void) -> SecureDownloadTrustCallbackResult,
73>;
74
75/// This callback is used called after trust has been evaluated.
76///
77/// Parameter `trustRef`: The trustRef for this evaluation
78///
79/// Parameter `result`: The result of the evaluation (See the SecTrust documentation).
80///
81/// Parameter `evaluateContext`: user defined.
82///
83/// Returns: A SecTrustResultType. Return the value passed in result if you
84/// do not want to change the evaluation result.
85///
86/// See also [Apple's documentation](https://developer.apple.com/documentation/security/securedownloadtrustevaluatecallback?language=objc)
87#[cfg(feature = "SecTrust")]
88pub type SecureDownloadTrustEvaluateCallback = Option<
89 unsafe extern "C-unwind" fn(
90 *mut SecTrust,
91 SecTrustResultType,
92 *mut c_void,
93 ) -> SecTrustResultType,
94>;
95
96extern "C-unwind" {
97 /// Create a SecureDownloadRef for use during the Secure Download process.
98 ///
99 /// Parameter `ticket`: The download ticket.
100 ///
101 /// Parameter `setup`: Called before trust is verified for each signer of the ticket.
102 /// This allows the user to modify the SecTrustRef if needed
103 /// (see the SecTrust documentation). Returns a SecureDownloadTrustCallbackResult (see).
104 ///
105 /// Parameter `setupContext`: User defined. Passed as a parameter to the setupCallback.
106 ///
107 /// Parameter `evaluate`: Called after SecTrustEvaluate has been called for a
108 /// signer if the result was not trusted. This allows
109 /// the developer to query the user as to whether or not
110 /// to trust the signer. Returns a SecTrustResultType
111 ///
112 /// Parameter `evaluateContext`: User defined. Passed as a parameter to the evaluate callback.
113 ///
114 /// Parameter `downloadRef`: The returned reference.
115 ///
116 /// Returns: Returns errSecureDownloadInvalidTicket if the ticket was invalid. Otherwise
117 /// see "Security Error Codes" (SecBase.h).
118 /// .
119 #[cfg(feature = "SecTrust")]
120 #[deprecated = "SecureDownload is not supported"]
121 pub fn SecureDownloadCreateWithTicket(
122 ticket: Option<&CFData>,
123 setup: SecureDownloadTrustSetupCallback,
124 setup_context: *mut c_void,
125 evaluate: SecureDownloadTrustEvaluateCallback,
126 evaluate_context: *mut c_void,
127 download_ref: *mut SecureDownloadRef,
128 ) -> OSStatus;
129}
130
131extern "C-unwind" {
132 /// Return a list of URL's from which the data can be downloaded. The first
133 /// URL in the list is the preferred download location. The other URL's are
134 /// backup locations in case earlier locations in the list could not be
135 /// accessed.
136 ///
137 /// Parameter `downloadRef`: A SecureDownloadRef instance.
138 ///
139 /// Parameter `urls`: On return, the list of URL's to download. Format is a CFArray of CFURL's.
140 ///
141 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
142 #[deprecated = "SecureDownload is not supported"]
143 pub fn SecureDownloadCopyURLs(
144 download_ref: SecureDownloadRef,
145 urls: *mut *const CFArray,
146 ) -> OSStatus;
147}
148
149extern "C-unwind" {
150 /// Return the printable name of this download ticket.
151 ///
152 /// Parameter `downloadRef`: A SecureDownloadRef instance.
153 ///
154 /// Parameter `name`: On output, the download name.
155 ///
156 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
157 #[deprecated = "SecureDownload is not supported"]
158 pub fn SecureDownloadCopyName(
159 download_ref: SecureDownloadRef,
160 name: *mut *const CFString,
161 ) -> OSStatus;
162}
163
164extern "C-unwind" {
165 /// Return the date the downlooad ticket was created.
166 ///
167 /// Parameter `downloadRef`: A SecureDownloadRef instance.
168 ///
169 /// Returns: A result code.
170 #[deprecated = "SecureDownload is not supported"]
171 pub fn SecureDownloadCopyCreationDate(
172 download_ref: SecureDownloadRef,
173 date: *mut *const CFDate,
174 ) -> OSStatus;
175}
176
177extern "C-unwind" {
178 /// Return the size of the expected download.
179 ///
180 /// Parameter `downloadRef`: A SecureDownloadRef instance.
181 ///
182 /// Parameter `downloadSize`: On output, the size of the download.
183 ///
184 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
185 #[deprecated = "SecureDownload is not supported"]
186 pub fn SecureDownloadGetDownloadSize(
187 download_ref: SecureDownloadRef,
188 download_size: *mut i64,
189 ) -> OSStatus;
190}
191
192extern "C-unwind" {
193 /// Check data received during Secure Download for validity.
194 /// Call this function each time data is received.
195 ///
196 /// Parameter `downloadRef`: A SecureDownloadRef instance.
197 ///
198 /// Parameter `data`: The data to check.
199 ///
200 /// Returns: Returns errSecureDownloadInvalidDownload if data is invalid. Otherwise
201 /// see "Security Error Codes" (SecBase.h).
202 #[deprecated = "SecureDownload is not supported"]
203 pub fn SecureDownloadUpdateWithData(
204 download_ref: SecureDownloadRef,
205 data: Option<&CFData>,
206 ) -> OSStatus;
207}
208
209extern "C-unwind" {
210 /// Concludes the secure download process. Call this after all data has been received.
211 ///
212 /// Parameter `downloadRef`: A SecureDownloadRef instance.
213 ///
214 /// Returns: Returns errSecureDownloadInvalidDownload if data is invalid. Otherwise
215 /// see "Security Error Codes" (SecBase.h).
216 #[deprecated = "SecureDownload is not supported"]
217 pub fn SecureDownloadFinished(download_ref: SecureDownloadRef) -> OSStatus;
218}
219
220extern "C-unwind" {
221 /// Releases a SecureDownloadRef.
222 ///
223 /// Parameter `downloadRef`: The SecureDownloadRef to release.
224 ///
225 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
226 #[deprecated = "SecureDownload is not supported"]
227 pub fn SecureDownloadRelease(download_ref: SecureDownloadRef) -> OSStatus;
228}
229
230extern "C-unwind" {
231 /// Copies the ticket location from an x-securedownload URL.
232 ///
233 /// Parameter `url`: The x-securedownload URL.
234 ///
235 /// Parameter `ticketLocation`: On exit, the URL of the ticket.
236 ///
237 /// Returns: A result code. See "Security Error Codes" (SecBase.h).
238 #[deprecated = "SecureDownload is not supported"]
239 pub fn SecureDownloadCopyTicketLocation(
240 url: Option<&CFURL>,
241 ticket_location: *mut *const CFURL,
242 ) -> OSStatus;
243}