objc2_security/generated/SecCustomTransform.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::marker::{PhantomData, PhantomPinned};
5use core::ptr::NonNull;
6#[cfg(feature = "objc2")]
7use objc2::__framework_prelude::*;
8use objc2_core_foundation::*;
9
10use crate::*;
11
12/// Within a transform, each of its attributes is a collection of
13/// "metadata attributes", of which name and current value are two. The
14/// value is directly visible from outside; the other metadata
15/// attributes direct the behavior of the transform and
16/// its function within its group. Each attribute may be tailored by setting its metadata.
17///
18///
19/// The actual value of the attribute. The attribute value has a default
20/// value of NULL.
21///
22///
23/// The name of the attribute. Attribute name is read only and may
24/// not be used with the SecTransformSetAttributeBlock block.
25///
26///
27/// A direct reference to an attribute's value. This reference allows
28/// for direct access to an attribute without having to look up the
29/// attribute by name. If a transform commonly uses an attribute, using
30/// a reference speeds up the use of that attribute. Attribute
31/// references are not visible or valid from outside of the particular
32/// transform instance.
33///
34///
35/// Specifies if an attribute must have a non NULL value set or have an
36/// incoming connection before the transform starts to execute. This
37/// metadata has a default value of true for the input attribute, but
38/// false for all other attributes.
39///
40///
41/// Specifies if an attribute must have an outbound connection. This
42/// metadata has a default value of true for the output attribute but is
43/// false for all other attributes.
44///
45///
46/// Determines if the AttributeSetNotification notification or the
47/// ProcessData blocks are deferred until SecExecuteTransform is called.
48/// This metadata value has a default value of true for the input
49/// attribute but is false for all other attributes.
50///
51///
52/// Specifies if the attribute should expect a series of values ending
53/// with a NULL to specify the end of the data stream. This metadata has
54/// a default value of true for the input and output attributes, but is
55/// false for all other attributes.
56///
57///
58/// A Transform group is a directed graph which is typically acyclic.
59/// Some transforms need to work with cycles. For example, a transform
60/// that emits a header and trailer around the data of another transform
61/// must create a cycle. If this metadata set to true, no error is
62/// returned if a cycle is detected for this attribute.
63///
64///
65/// Specifies if this attribute should be written out when creating the
66/// external representation of this transform. This metadata has a
67/// default value of true.
68///
69///
70/// This metadata value is true if the attribute has an outbound
71/// connection. This metadata is read only.
72///
73///
74/// This metadata value is true if the attribute has an inbound
75/// connection. This metadata is read only.
76///
77/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformmetaattributetype?language=objc)
78// NS_ENUM
79#[deprecated = "SecTransform is no longer supported"]
80#[repr(transparent)]
81#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
82pub struct SecTransformMetaAttributeType(pub CFIndex);
83impl SecTransformMetaAttributeType {
84 #[doc(alias = "kSecTransformMetaAttributeValue")]
85 #[deprecated = "SecTransform is no longer supported"]
86 pub const Value: Self = Self(0);
87 #[doc(alias = "kSecTransformMetaAttributeName")]
88 #[deprecated = "SecTransform is no longer supported"]
89 pub const Name: Self = Self(1);
90 #[doc(alias = "kSecTransformMetaAttributeRef")]
91 #[deprecated = "SecTransform is no longer supported"]
92 pub const Ref: Self = Self(2);
93 #[doc(alias = "kSecTransformMetaAttributeRequired")]
94 #[deprecated = "SecTransform is no longer supported"]
95 pub const Required: Self = Self(3);
96 #[doc(alias = "kSecTransformMetaAttributeRequiresOutboundConnection")]
97 #[deprecated = "SecTransform is no longer supported"]
98 pub const RequiresOutboundConnection: Self = Self(4);
99 #[doc(alias = "kSecTransformMetaAttributeDeferred")]
100 #[deprecated = "SecTransform is no longer supported"]
101 pub const Deferred: Self = Self(5);
102 #[doc(alias = "kSecTransformMetaAttributeStream")]
103 #[deprecated = "SecTransform is no longer supported"]
104 pub const Stream: Self = Self(6);
105 #[doc(alias = "kSecTransformMetaAttributeCanCycle")]
106 #[deprecated = "SecTransform is no longer supported"]
107 pub const CanCycle: Self = Self(7);
108 #[doc(alias = "kSecTransformMetaAttributeExternalize")]
109 #[deprecated = "SecTransform is no longer supported"]
110 pub const Externalize: Self = Self(8);
111 #[doc(alias = "kSecTransformMetaAttributeHasOutboundConnections")]
112 #[deprecated = "SecTransform is no longer supported"]
113 pub const HasOutboundConnections: Self = Self(9);
114 #[doc(alias = "kSecTransformMetaAttributeHasInboundConnection")]
115 #[deprecated = "SecTransform is no longer supported"]
116 pub const HasInboundConnection: Self = Self(10);
117}
118
119#[cfg(feature = "objc2")]
120unsafe impl Encode for SecTransformMetaAttributeType {
121 const ENCODING: Encoding = CFIndex::ENCODING;
122}
123
124#[cfg(feature = "objc2")]
125unsafe impl RefEncode for SecTransformMetaAttributeType {
126 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
127}
128
129/// A direct reference to an attribute. Using an attribute
130/// reference speeds up using an attribute's value by removing
131/// the need to look
132/// it up by name.
133///
134/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformattribute?language=objc)
135#[doc(alias = "SecTransformAttributeRef")]
136#[deprecated = "SecTransform is no longer supported"]
137pub type SecTransformAttribute = CFType;
138
139/// This type signifies that either a CFStringRef or
140/// a SecTransformAttributeRef may be used.
141///
142/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformstringorattribute?language=objc)
143#[doc(alias = "SecTransformStringOrAttributeRef")]
144#[deprecated = "SecTransform is no longer supported"]
145pub type SecTransformStringOrAttribute = CFType;
146
147/// A block that overrides the default behavior of a
148/// custom transform.
149///
150///
151/// Returns: If this block is used to overide the
152/// kSecTransformActionExternalizeExtraData action then the
153/// block should return a CFDictinaryRef of the custom
154/// items to be exported. For all of other actions the
155/// block should return NULL. If an error occurs for
156/// any action, the block should return a CFErrorRef.
157///
158///
159/// A SecTransformTransformActionBlock block is used to
160/// override
161/// the default behavior of a custom transform. This block is
162/// associated with the SecTransformOverrideTransformAction
163/// block.
164///
165/// The behaviors that can be overridden are:
166///
167/// kSecTransformActionCanExecute
168/// Determine if the transform has all of the data
169/// needed to run.
170///
171/// kSecTransformActionStartingExecution
172/// Called just before running ProcessData.
173///
174/// kSecTransformActionFinalize
175/// Called just before deleting the custom transform.
176///
177/// kSecTransformActionExternalizeExtraData
178/// Called to allow for writing out custom data
179/// to be exported.
180///
181/// Example:
182/// <pre>
183///
184/// ```text
185/// SecTransformImplementationRef ref;
186/// CFErrorRef error = NULL;
187///
188/// error = SecTransformSetTransformAction(ref, kSecTransformActionStartingExecution,
189/// ^{
190/// // This is where the work to initialize any data needed
191/// // before running
192/// CFErrorRef result = DoMyInitialization();
193/// return result;
194/// });
195///
196/// SecTransformTransformActionBlock actionBlock =
197/// ^{
198/// // This is where the work to clean up any existing data
199/// // before running
200/// CFErrorRef result = DoMyFinalization();
201/// return result;
202/// };
203///
204/// error = SecTransformSetTransformAction(ref, kSecTransformActionFinalize,
205/// actionBlock);
206/// ```
207///
208/// </pre>
209///
210/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformactionblock?language=objc)
211#[deprecated = "SecTransform is no longer supported"]
212#[cfg(feature = "block2")]
213pub type SecTransformActionBlock = *mut block2::DynBlock<dyn Fn() -> *const CFType>;
214
215/// A block used to override the default attribute handling
216/// for when an attribute is set.
217///
218///
219/// Parameter `attribute`: The attribute whose default is being overridden or NULL
220/// if this is a generic notification override
221///
222///
223/// Parameter `value`: Proposed new value for the attribute.
224///
225///
226/// Returns: The new value of the attribute if successful. If an
227/// error occurred then a CFErrorRef is returned. If a transform
228/// needs to have a CFErrorRef as the value of an attribute,
229/// then the CFErrorRef needs to be placed into a container such
230/// as a CFArrayRef, CFDictionaryRef etc.
231///
232///
233/// See the example program in this header for more details.
234///
235/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformattributeactionblock?language=objc)
236#[deprecated = "SecTransform is no longer supported"]
237#[cfg(feature = "block2")]
238pub type SecTransformAttributeActionBlock =
239 *mut block2::DynBlock<dyn Fn(NonNull<SecTransformAttribute>, NonNull<CFType>) -> *const CFType>;
240
241/// A block used to override the default data handling
242/// for a transform.
243///
244///
245/// Parameter `data`: The data to be processed. When this block is used
246/// to to implement the kSecTransformActionProcessData action,
247/// the data is the input data that is to be processed into the
248/// output data. When this block is used to implement the
249/// kSecTransformActionInternalizeExtraData action, the data is
250/// a CFDictionaryRef that contains the data that needs to be
251/// imported.
252///
253///
254/// Returns: When this block is used to implment the
255/// kSecTransformActionProcessData action, the value returned
256/// is to be the data that will be passed to the output
257/// attribute. If an error occured while processing the input
258/// data then the block should return a CFErrorRef.
259///
260/// When this block is used to implement the
261/// kSecTransformActionInternalizeExtraData action then this block
262/// should return NULL or a CFErrorRef if an error occurred.
263///
264///
265/// See the example program for more details.
266///
267/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformdatablock?language=objc)
268#[cfg(feature = "block2")]
269pub type SecTransformDataBlock = *mut block2::DynBlock<dyn Fn(NonNull<CFType>) -> *const CFType>;
270
271/// This is the block that is returned from an
272/// implementation of a CreateTransform function.
273///
274///
275/// Returns: A CFErrorRef if an error occurred or NULL.
276///
277///
278/// The instance block that is returned from the
279/// developers CreateTransform function, defines
280/// the behavior of a custom attribute. Please
281/// see the example at the head of this file.
282///
283/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransforminstanceblock?language=objc)
284#[cfg(feature = "block2")]
285pub type SecTransformInstanceBlock = *mut block2::DynBlock<dyn Fn() -> *mut CFError>;
286
287/// [Apple's documentation](https://developer.apple.com/documentation/security/opaquesectransformimplementation?language=objc)
288#[repr(C)]
289#[derive(Debug)]
290pub struct OpaqueSecTransformImplementation {
291 inner: [u8; 0],
292 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
293}
294
295#[cfg(feature = "objc2")]
296unsafe impl RefEncode for OpaqueSecTransformImplementation {
297 const ENCODING_REF: Encoding =
298 Encoding::Pointer(&Encoding::Struct("OpaqueSecTransformImplementation", &[]));
299}
300
301/// The SecTransformImplementationRef is a pointer to a block
302/// that implements an instance of a transform.
303///
304/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformimplementationref?language=objc)
305pub type SecTransformImplementationRef = *const OpaqueSecTransformImplementation;
306
307/// Be notified when a attribute is set. The supplied block is
308/// called when the attribute is set. This can be done for a
309/// specific named attribute or all attributes.
310///
311///
312/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
313/// of a custom transform.
314///
315///
316/// Parameter `action`: The behavior to be set. This can be one of the following
317/// actions:
318///
319/// kSecTransformActionAttributeNotification - add a block that
320/// is called when an attribute is set. If the name is NULL,
321/// then the supplied block is called for all set attributes
322/// except for ones that have a specific block as a handler.
323///
324/// For example, if there is a handler for the attribute "foo"
325/// and for all attributes, the "foo" handler is called when the
326/// "foo" attribute is set, but all other attribute sets will
327/// call the NULL handler.
328///
329/// The kSecTransformActionProcessData action is a special case
330/// of a SecTransformSetAttributeAction action. If this is
331/// called on the input attribute then it will overwrite any
332/// kSecTransformActionProcessData that was set.
333///
334/// kSecTransformActionAttributeValidation Add a block that is
335/// called to validate the input to an attribute.
336///
337///
338/// Parameter `attribute`: The name of the attribute that will be handled. An attribute
339/// reference may also be given here. A NULL name indicates that
340/// the supplied action is for all attributes.
341///
342///
343/// Parameter `newAction`: A SecTransformAttributeActionBlock which implements the
344/// behavior.
345///
346///
347/// Returns: A CFErrorRef if an error occured NULL otherwise.
348///
349///
350/// This function may be called multiple times for either a
351/// named attribute or for all attributes when the attribute
352/// parameter is NULL. Each time the API is called it overwrites
353/// what was there previously.
354///
355/// # Safety
356///
357/// - `ref` must be a valid pointer.
358/// - `attribute` should be of the correct type.
359/// - `new_action` must be a valid pointer.
360#[cfg(feature = "block2")]
361#[deprecated = "SecTransform is no longer supported"]
362#[inline]
363pub unsafe extern "C-unwind" fn SecTransformSetAttributeAction(
364 r#ref: SecTransformImplementationRef,
365 action: &CFString,
366 attribute: Option<&SecTransformStringOrAttribute>,
367 new_action: SecTransformAttributeActionBlock,
368) -> Option<CFRetained<CFError>> {
369 extern "C-unwind" {
370 fn SecTransformSetAttributeAction(
371 r#ref: SecTransformImplementationRef,
372 action: &CFString,
373 attribute: Option<&SecTransformStringOrAttribute>,
374 new_action: SecTransformAttributeActionBlock,
375 ) -> Option<NonNull<CFError>>;
376 }
377 let ret = unsafe { SecTransformSetAttributeAction(r#ref, action, attribute, new_action) };
378 ret.map(|ret| unsafe { CFRetained::retain(ret) })
379}
380
381/// Change the way a custom transform will do data processing.
382/// When the action parameter is kSecTransformActionProcessData
383/// The newAction block will change the way that input data is
384/// processed to become the output data. When the action
385/// parameter is kSecTransformActionInternalizeExtraData it will
386/// change the way a custom transform reads in data to be
387/// imported into the transform.
388///
389///
390/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
391/// of a custom transform.
392///
393///
394/// Parameter `action`: The action being overridden. This value should be one of the
395/// following:
396/// kSecTransformActionProcessData
397/// Change the way that input data is processed into the
398/// output data. The default behavior is to simply copy
399/// the input data to the output attribute.
400///
401/// The kSecTransformActionProcessData action is really
402/// a special case of a SecTransformSetAttributeAction
403/// action. If you call this method with
404/// kSecTransformActionProcessData it would overwrite
405/// any kSecTransformActionAttributeNotification action
406/// that was set proviously
407///
408/// kSecTransformActionInternalizeExtraData
409/// Change the way that custom externalized data is
410/// imported into the transform. The default behavior
411/// is to do nothing.
412///
413///
414/// Parameter `newAction`: A SecTransformDataBlock which implements the behavior.
415///
416/// If the action parameter is kSecTransformActionProcessData then
417/// this block will be called to process the input data into the
418/// output data.
419///
420/// if the action parameter is kSecTransformActionInternalizeExtraData then
421/// this block will called to input custom data into the transform.
422///
423///
424/// Returns: A CFErrorRef is an error occured NULL otherwise.
425///
426///
427/// This API may be called multiple times. Each time the API is called
428/// it overwrites what was there previously.
429///
430/// # Safety
431///
432/// - `ref` must be a valid pointer.
433/// - `new_action` must be a valid pointer.
434#[cfg(feature = "block2")]
435#[deprecated = "SecTransform is no longer supported"]
436#[inline]
437pub unsafe extern "C-unwind" fn SecTransformSetDataAction(
438 r#ref: SecTransformImplementationRef,
439 action: &CFString,
440 new_action: SecTransformDataBlock,
441) -> Option<CFRetained<CFError>> {
442 extern "C-unwind" {
443 fn SecTransformSetDataAction(
444 r#ref: SecTransformImplementationRef,
445 action: &CFString,
446 new_action: SecTransformDataBlock,
447 ) -> Option<NonNull<CFError>>;
448 }
449 let ret = unsafe { SecTransformSetDataAction(r#ref, action, new_action) };
450 ret.map(|ret| unsafe { CFRetained::retain(ret) })
451}
452
453/// # Safety
454///
455/// - `ref` must be a valid pointer.
456/// - `new_action` must be a valid pointer.
457#[cfg(feature = "block2")]
458#[deprecated = "SecTransform is no longer supported"]
459#[inline]
460pub unsafe extern "C-unwind" fn SecTransformSetTransformAction(
461 r#ref: SecTransformImplementationRef,
462 action: &CFString,
463 new_action: SecTransformActionBlock,
464) -> Option<CFRetained<CFError>> {
465 extern "C-unwind" {
466 fn SecTransformSetTransformAction(
467 r#ref: SecTransformImplementationRef,
468 action: &CFString,
469 new_action: SecTransformActionBlock,
470 ) -> Option<NonNull<CFError>>;
471 }
472 let ret = unsafe { SecTransformSetTransformAction(r#ref, action, new_action) };
473 ret.map(|ret| unsafe { CFRetained::retain(ret) })
474}
475
476/// Allow a custom transform to get an attribute value
477///
478///
479/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
480/// of a custom transform.
481///
482///
483/// Parameter `attribute`: The name or the attribute handle of the attribute whose
484/// value is to be retrieved.
485///
486///
487/// Parameter `type`: The type of data to be retrieved for the attribute. See the
488/// discussion on SecTransformMetaAttributeType for details.
489///
490///
491/// Returns: The value of the attribute.
492///
493/// # Safety
494///
495/// - `ref` must be a valid pointer.
496/// - `attribute` should be of the correct type.
497#[deprecated]
498#[inline]
499pub unsafe extern "C-unwind" fn SecTranformCustomGetAttribute(
500 r#ref: SecTransformImplementationRef,
501 attribute: &SecTransformStringOrAttribute,
502 r#type: SecTransformMetaAttributeType,
503) -> Option<CFRetained<CFType>> {
504 extern "C-unwind" {
505 fn SecTranformCustomGetAttribute(
506 r#ref: SecTransformImplementationRef,
507 attribute: &SecTransformStringOrAttribute,
508 r#type: SecTransformMetaAttributeType,
509 ) -> Option<NonNull<CFType>>;
510 }
511 let ret = unsafe { SecTranformCustomGetAttribute(r#ref, attribute, r#type) };
512 ret.map(|ret| unsafe { CFRetained::retain(ret) })
513}
514
515/// Allow a custom transform to get an attribute value
516///
517///
518/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
519/// of a custom transform.
520///
521///
522/// Parameter `attribute`: The name or the attribute handle of the attribute whose
523/// value is to be retrieved.
524///
525///
526/// Parameter `type`: The type of data to be retrieved for the attribute. See the
527/// discussion on SecTransformMetaAttributeType for details.
528///
529///
530/// Returns: The value of the attribute.
531///
532/// # Safety
533///
534/// - `ref` must be a valid pointer.
535/// - `attribute` should be of the correct type.
536#[deprecated = "SecTransform is no longer supported"]
537#[inline]
538pub unsafe extern "C-unwind" fn SecTransformCustomGetAttribute(
539 r#ref: SecTransformImplementationRef,
540 attribute: &SecTransformStringOrAttribute,
541 r#type: SecTransformMetaAttributeType,
542) -> Option<CFRetained<CFType>> {
543 extern "C-unwind" {
544 #[link_name = "SecTranformCustomGetAttribute"]
545 fn SecTransformCustomGetAttribute(
546 r#ref: SecTransformImplementationRef,
547 attribute: &SecTransformStringOrAttribute,
548 r#type: SecTransformMetaAttributeType,
549 ) -> Option<NonNull<CFType>>;
550 }
551 let ret = unsafe { SecTransformCustomGetAttribute(r#ref, attribute, r#type) };
552 ret.map(|ret| unsafe { CFRetained::retain(ret) })
553}
554
555/// Allow a custom transform to set an attribute value
556///
557///
558/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
559/// of a custom transform.
560///
561///
562/// Parameter `attribute`: The name or the attribute handle of the attribute whose
563/// value is to be set.
564///
565///
566/// Parameter `type`: The type of data to be retrieved for the attribute. See the
567/// discussion on SecTransformMetaAttributeType for details.
568///
569///
570/// Parameter `value`: The new value for the attribute
571///
572///
573/// Returns: A CFErrorRef if an error occured , NULL otherwise.
574///
575///
576/// Unlike the SecTransformSetAttribute API this API can set
577/// attribute values while a transform is executing. These
578/// values are limited to the custom transform instance that
579/// is bound to the ref parameter.
580///
581/// # Safety
582///
583/// - `ref` must be a valid pointer.
584/// - `attribute` should be of the correct type.
585/// - `value` should be of the correct type.
586#[deprecated = "SecTransform is no longer supported"]
587#[inline]
588pub unsafe extern "C-unwind" fn SecTransformCustomSetAttribute(
589 r#ref: SecTransformImplementationRef,
590 attribute: &SecTransformStringOrAttribute,
591 r#type: SecTransformMetaAttributeType,
592 value: Option<&CFType>,
593) -> Option<CFRetained<CFType>> {
594 extern "C-unwind" {
595 fn SecTransformCustomSetAttribute(
596 r#ref: SecTransformImplementationRef,
597 attribute: &SecTransformStringOrAttribute,
598 r#type: SecTransformMetaAttributeType,
599 value: Option<&CFType>,
600 ) -> Option<NonNull<CFType>>;
601 }
602 let ret = unsafe { SecTransformCustomSetAttribute(r#ref, attribute, r#type, value) };
603 ret.map(|ret| unsafe { CFRetained::retain(ret) })
604}
605
606/// Allows for putting a single value back for a specific
607/// attribute. This will stop the flow of data into the
608/// specified attribute until any attribute is changed for the
609/// transform instance bound to the ref parameter.
610///
611///
612/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
613/// of a custom transform.
614///
615///
616/// Parameter `attribute`: The name or the attribute handle of the attribute whose
617/// value is to be pushed back.
618///
619///
620/// Parameter `value`: The value being pushed back.
621///
622///
623/// Returns: A CFErrorRef if an error occured , NULL otherwise.
624///
625/// # Safety
626///
627/// - `ref` must be a valid pointer.
628/// - `attribute` should be of the correct type.
629/// - `value` should be of the correct type.
630#[deprecated = "SecTransform is no longer supported"]
631#[inline]
632pub unsafe extern "C-unwind" fn SecTransformPushbackAttribute(
633 r#ref: SecTransformImplementationRef,
634 attribute: &SecTransformStringOrAttribute,
635 value: &CFType,
636) -> Option<CFRetained<CFType>> {
637 extern "C-unwind" {
638 fn SecTransformPushbackAttribute(
639 r#ref: SecTransformImplementationRef,
640 attribute: &SecTransformStringOrAttribute,
641 value: &CFType,
642 ) -> Option<NonNull<CFType>>;
643 }
644 let ret = unsafe { SecTransformPushbackAttribute(r#ref, attribute, value) };
645 ret.map(|ret| unsafe { CFRetained::retain(ret) })
646}
647
648/// A function pointer to a function that will create a
649/// new instance of a custom transform.
650///
651///
652/// Parameter `name`: The name of the new custom transform. This name MUST be
653/// unique.
654///
655///
656/// Parameter `newTransform`: The newly created transform Ref.
657///
658///
659/// Parameter `ref`: A reference that is bound to an instance of a custom
660/// transform.
661///
662///
663/// Returns: A SecTransformInstanceBlock that is used to create a new
664/// instance of a custom transform.
665///
666///
667/// The CreateTransform function creates a new transform. The
668/// SecTransformInstanceBlock that is returned from this
669/// function provides the implementation of all of the overrides
670/// necessary to create the custom transform. This returned
671/// SecTransformInstanceBlock is also where the "instance"
672/// variables for the custom transform may be defined. See the
673/// example in the header section of this file for more detail.
674///
675/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformcreatefp?language=objc)
676#[deprecated = "SecTransform is no longer supported"]
677#[cfg(all(feature = "SecTransform", feature = "block2"))]
678pub type SecTransformCreateFP = Option<
679 unsafe extern "C-unwind" fn(
680 NonNull<CFString>,
681 NonNull<SecTransform>,
682 SecTransformImplementationRef,
683 ) -> SecTransformInstanceBlock,
684>;
685
686extern "C" {
687 /// Overrides the standard behavior that checks to see if all of the
688 /// required attributes either have been set or are connected to
689 /// another transform. When overriding the default behavior the
690 /// developer can decided what the necessary data is to have for a
691 /// transform to be considered 'ready to run'. Returning NULL means
692 /// that the transform is ready to be run. If the transform is NOT
693 /// ready to run then the override should return a CFErrorRef
694 /// stipulating the error.
695 ///
696 /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactioncanexecute?language=objc)
697 #[deprecated = "SecTransform is no longer supported"]
698 pub static kSecTransformActionCanExecute: &'static CFString;
699}
700
701extern "C" {
702 /// Overrides the standard behavior that occurs just before starting
703 /// execution of a custom transform. This is typically overridden
704 /// to allow for initialization. This is used with the
705 /// SecTransformOverrideTransformAction block.
706 ///
707 /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionstartingexecution?language=objc)
708 #[deprecated = "SecTransform is no longer supported"]
709 pub static kSecTransformActionStartingExecution: &'static CFString;
710}
711
712extern "C" {
713 /// Overrides the standard behavior that occurs just before deleting
714 /// a custom transform. This is typically overridden to allow for
715 /// memory clean up of a custom transform. This is used with the
716 /// SecTransformOverrideTransformAction block.
717 ///
718 /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionfinalize?language=objc)
719 #[deprecated = "SecTransform is no longer supported"]
720 pub static kSecTransformActionFinalize: &'static CFString;
721}
722
723extern "C" {
724 /// Allows for adding to the data that is stored using an override
725 /// to the kSecTransformActionExternalizeExtraData block. The output
726 /// of this override is a dictionary that contains the custom
727 /// externalized data. A common use of this override is to write out
728 /// a version number of a custom transform.
729 ///
730 /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionexternalizeextradata?language=objc)
731 #[deprecated = "SecTransform is no longer supported"]
732 pub static kSecTransformActionExternalizeExtraData: &'static CFString;
733}
734
735extern "C" {
736 /// Overrides the standard data processing for an attribute. This is
737 /// almost exclusively used for processing the input attribute as
738 /// the return value of their block sets the output attribute. This
739 /// is used with the SecTransformOverrideAttributeAction block.
740 ///
741 /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionprocessdata?language=objc)
742 #[deprecated = "SecTransform is no longer supported"]
743 pub static kSecTransformActionProcessData: &'static CFString;
744}
745
746extern "C" {
747 /// Overrides the standard processing that occurs when externalized
748 /// data is used to create a transform. This is closely tied to the
749 /// kSecTransformActionExternalizeExtraData override. The 'normal'
750 /// attributes are read into the new transform and then this is
751 /// called to read in the items that were written out using
752 /// kSecTransformActionExternalizeExtraData override. A common use
753 /// of this override would be to read in the version number of the
754 /// externalized custom transform.
755 ///
756 /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactioninternalizeextradata?language=objc)
757 #[deprecated = "SecTransform is no longer supported"]
758 pub static kSecTransformActionInternalizeExtraData: &'static CFString;
759}
760
761extern "C" {
762 /// Allows a block to be called when an attribute is set. This
763 /// allows for caching the value as a block variable in the instance
764 /// block or transmogrifying the data to be set. This action is
765 /// where a custom transform would be able to do processing outside
766 /// of processing input to output as process data does. One the
767 /// data has been processed the action block can call
768 /// SecTransformCustomSetAttribute to update and other attribute.
769 ///
770 /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionattributenotification?language=objc)
771 #[deprecated = "SecTransform is no longer supported"]
772 pub static kSecTransformActionAttributeNotification: &'static CFString;
773}
774
775extern "C" {
776 /// Allows a block to be called to validate the new value for an
777 /// attribute. The default is no validation and any CFTypeRef can
778 /// be used as the new value. The block should return NULL if the
779 /// value is ok to set on the attribute or a CFErrorRef otherwise.
780 ///
781 /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionattributevalidation?language=objc)
782 #[deprecated = "SecTransform is no longer supported"]
783 pub static kSecTransformActionAttributeValidation: &'static CFString;
784}
785
786/// Register a new custom transform so that it may be used to
787/// process data
788///
789///
790/// Parameter `uniqueName`: A unique name for this custom transform. It is recommended
791/// that a reverse DNS name be used for the name of your custom
792/// transform
793///
794///
795/// Parameter `createTransformFunction`: A SecTransformCreateFP function pointer. The function must
796/// return a SecTransformInstanceBlock block that block_copy has
797/// been called on before returning the block. Failure to call
798/// block_copy will cause undefined behavior.
799///
800///
801/// Parameter `error`: This pointer is set if an error occurred. This value
802/// may be NULL if you do not want an error returned.
803///
804///
805/// Returns: True if the custom transform was registered false otherwise
806///
807/// # Safety
808///
809/// - `create_transform_function` must be implemented correctly.
810/// - `error` must be a valid pointer or null.
811#[cfg(all(feature = "SecTransform", feature = "block2"))]
812#[deprecated = "SecTransform is no longer supported"]
813#[inline]
814pub unsafe extern "C-unwind" fn SecTransformRegister(
815 unique_name: &CFString,
816 create_transform_function: SecTransformCreateFP,
817 error: *mut *mut CFError,
818) -> bool {
819 extern "C-unwind" {
820 fn SecTransformRegister(
821 unique_name: &CFString,
822 create_transform_function: SecTransformCreateFP,
823 error: *mut *mut CFError,
824 ) -> Boolean;
825 }
826 let ret = unsafe { SecTransformRegister(unique_name, create_transform_function, error) };
827 ret != 0
828}
829
830/// Creates a transform computation object.
831///
832///
833/// Parameter `name`: The type of transform to create, must have been registered
834/// by SecTransformRegister, or be a system pre-defined
835/// transform type.
836///
837///
838/// Parameter `error`: A pointer to a CFErrorRef. This pointer is set if an error
839/// occurred. This value may be NULL if you do not want an
840/// error returned.
841///
842///
843/// Returns: A pointer to a SecTransformRef object. This object must be
844/// released with CFRelease when you are done with it. This
845/// function returns NULL if an error occurred.
846///
847/// # Safety
848///
849/// `error` must be a valid pointer or null.
850#[cfg(feature = "SecTransform")]
851#[deprecated = "SecTransform is no longer supported"]
852#[inline]
853pub unsafe extern "C-unwind" fn SecTransformCreate(
854 name: &CFString,
855 error: *mut *mut CFError,
856) -> Option<CFRetained<SecTransform>> {
857 extern "C-unwind" {
858 fn SecTransformCreate(
859 name: &CFString,
860 error: *mut *mut CFError,
861 ) -> Option<NonNull<SecTransform>>;
862 }
863 let ret = unsafe { SecTransformCreate(name, error) };
864 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
865}
866
867/// Returns back A CFTypeRef from inside a processData
868/// override that says that while no data is being returned
869/// the transform is still active and awaiting data.
870///
871///
872/// Returns: A 'special' value that allows that specifies that the
873/// transform is still active and awaiting data.
874///
875///
876/// The standard behavior for the ProcessData override is that
877/// it will receive a CFDataRef and it processes that data and
878/// returns a CFDataRef that contains the processed data. When
879/// there is no more data to process the ProcessData override
880/// block is called one last time with a NULL CFDataRef. The
881/// ProcessData block should/must return the NULL CFDataRef to
882/// complete the processing. This model does not work well for
883/// some transforms. For example a digest transform needs to see
884/// ALL of the data that is being digested before it can send
885/// out the digest value.
886///
887/// If a ProcessData block has no data to return, it can return
888/// SecTransformNoData(), which informs the transform system
889/// that there is no data to pass on to the next transform.
890#[deprecated = "SecTransform is no longer supported"]
891#[inline]
892pub unsafe extern "C-unwind" fn SecTransformNoData() -> CFRetained<CFType> {
893 extern "C-unwind" {
894 fn SecTransformNoData() -> Option<NonNull<CFType>>;
895 }
896 let ret = unsafe { SecTransformNoData() };
897 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
898 unsafe { CFRetained::retain(ret) }
899}