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)
135pub type SecTransformAttribute = CFType;
136
137/// This type signifies that either a CFStringRef or
138/// a SecTransformAttributeRef may be used.
139///
140/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformstringorattribute?language=objc)
141pub type SecTransformStringOrAttribute = CFType;
142
143/// A block that overrides the default behavior of a
144/// custom transform.
145///
146///
147/// Returns: If this block is used to overide the
148/// kSecTransformActionExternalizeExtraData action then the
149/// block should return a CFDictinaryRef of the custom
150/// items to be exported. For all of other actions the
151/// block should return NULL. If an error occurs for
152/// any action, the block should return a CFErrorRef.
153///
154///
155/// A SecTransformTransformActionBlock block is used to
156/// override
157/// the default behavior of a custom transform. This block is
158/// associated with the SecTransformOverrideTransformAction
159/// block.
160///
161/// The behaviors that can be overridden are:
162///
163/// kSecTransformActionCanExecute
164/// Determine if the transform has all of the data
165/// needed to run.
166///
167/// kSecTransformActionStartingExecution
168/// Called just before running ProcessData.
169///
170/// kSecTransformActionFinalize
171/// Called just before deleting the custom transform.
172///
173/// kSecTransformActionExternalizeExtraData
174/// Called to allow for writing out custom data
175/// to be exported.
176///
177/// Example:
178/// <pre>
179///
180/// ```text
181///                     SecTransformImplementationRef ref;
182///                     CFErrorRef error = NULL;
183///
184///                     error = SecTransformSetTransformAction(ref, kSecTransformActionStartingExecution,
185///                     ^{
186///                         // This is where the work to initialize any data needed
187///                         // before running
188///                         CFErrorRef result = DoMyInitialization();
189///                         return result;
190///                     });
191///
192///                     SecTransformTransformActionBlock actionBlock =
193///                     ^{
194///                         // This is where the work to clean up any existing data
195///                         // before running
196///                         CFErrorRef result = DoMyFinalization();
197///                         return result;
198///                     };
199///
200///                     error = SecTransformSetTransformAction(ref, kSecTransformActionFinalize,
201///                         actionBlock);
202/// ```
203///
204/// </pre>
205///
206/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformactionblock?language=objc)
207#[cfg(feature = "block2")]
208pub type SecTransformActionBlock = *mut block2::DynBlock<dyn Fn() -> *const CFType>;
209
210/// A block used to override the default attribute handling
211/// for when an attribute is set.
212///
213///
214/// Parameter `attribute`: The attribute whose default is being overridden or NULL
215/// if this is a generic notification override
216///
217///
218/// Parameter `value`: Proposed new value for the attribute.
219///
220///
221/// Returns: The new value of the attribute if successful. If an
222/// error occurred then a CFErrorRef is returned. If a transform
223/// needs to have a CFErrorRef as the value of an attribute,
224/// then the CFErrorRef needs to be placed into a container such
225/// as a CFArrayRef, CFDictionaryRef etc.
226///
227///
228/// See the example program in this header for more details.
229///
230/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformattributeactionblock?language=objc)
231#[cfg(feature = "block2")]
232pub type SecTransformAttributeActionBlock =
233    *mut block2::DynBlock<dyn Fn(NonNull<SecTransformAttribute>, NonNull<CFType>) -> *const CFType>;
234
235/// A block used to override the default data handling
236/// for a transform.
237///
238///
239/// Parameter `data`: The data to be processed. When this block is used
240/// to to implement the kSecTransformActionProcessData action,
241/// the data is the input data that is to be processed into the
242/// output data.  When this block is used to implement the
243/// kSecTransformActionInternalizeExtraData action, the data is
244/// a CFDictionaryRef that contains the data that needs to be
245/// imported.
246///
247///
248/// Returns: When this block is used to implment the
249/// kSecTransformActionProcessData action, the value returned
250/// is to be the data that will be passed to the output
251/// attribute.  If an error occured while processing the input
252/// data then the block should return a CFErrorRef.
253///
254/// When this block is used to implement the
255/// kSecTransformActionInternalizeExtraData action then this block
256/// should return NULL or a CFErrorRef if an error occurred.
257///
258///
259/// See the example program for more details.
260///
261/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformdatablock?language=objc)
262#[cfg(feature = "block2")]
263pub type SecTransformDataBlock = *mut block2::DynBlock<dyn Fn(NonNull<CFType>) -> *const CFType>;
264
265/// This is the block that is returned from an
266/// implementation of a CreateTransform function.
267///
268///
269/// Returns: A CFErrorRef if an error occurred or NULL.
270///
271///
272/// The instance block that is returned from the
273/// developers CreateTransform function, defines
274/// the behavior of a custom attribute.  Please
275/// see the example at the head of this file.
276///
277/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransforminstanceblock?language=objc)
278#[cfg(feature = "block2")]
279pub type SecTransformInstanceBlock = *mut block2::DynBlock<dyn Fn() -> *mut CFError>;
280
281/// [Apple's documentation](https://developer.apple.com/documentation/security/opaquesectransformimplementation?language=objc)
282#[repr(C)]
283#[derive(Debug)]
284pub struct OpaqueSecTransformImplementation {
285    inner: [u8; 0],
286    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
287}
288
289#[cfg(feature = "objc2")]
290unsafe impl RefEncode for OpaqueSecTransformImplementation {
291    const ENCODING_REF: Encoding =
292        Encoding::Pointer(&Encoding::Struct("OpaqueSecTransformImplementation", &[]));
293}
294
295/// The SecTransformImplementationRef is a pointer to a block
296/// that implements an instance of a transform.
297///
298/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformimplementationref?language=objc)
299pub type SecTransformImplementationRef = *const OpaqueSecTransformImplementation;
300
301/// Be notified when a attribute is set. The supplied block is
302/// called when the attribute is set. This can be done for a
303/// specific named attribute or all attributes.
304///
305///
306/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
307/// of a custom transform.
308///
309///
310/// Parameter `action`: The behavior to be set. This can be one of the following
311/// actions:
312///
313/// kSecTransformActionAttributeNotification - add a block that
314/// is called when an attribute is set. If the name is NULL,
315/// then the supplied block is called for all set attributes
316/// except for ones that have a specific block as a handler.
317///
318/// For example, if there is a handler for the attribute "foo"
319/// and for all attributes, the "foo" handler is called when the
320/// "foo" attribute is set, but all other attribute sets will
321/// call the NULL handler.
322///
323/// The kSecTransformActionProcessData action is a special case
324/// of a SecTransformSetAttributeAction action.  If this is
325/// called on the input attribute then it will overwrite any
326/// kSecTransformActionProcessData that was set.
327///
328/// kSecTransformActionAttributeValidation Add a block that is
329/// called to validate the input to an attribute.
330///
331///
332/// Parameter `attribute`: The name of the attribute that will be handled. An attribute
333/// reference may also be given here. A NULL name indicates that
334/// the supplied action is for all attributes.
335///
336///
337/// Parameter `newAction`: A SecTransformAttributeActionBlock which implements the
338/// behavior.
339///
340///
341/// Returns: A CFErrorRef if an error occured NULL otherwise.
342///
343///
344/// This function may be called multiple times for either a
345/// named attribute or for all attributes when the attribute
346/// parameter is NULL. Each time the API is called it overwrites
347/// what was there previously.
348#[cfg(feature = "block2")]
349#[deprecated = "SecTransform is no longer supported"]
350#[inline]
351pub unsafe extern "C-unwind" fn SecTransformSetAttributeAction(
352    r#ref: SecTransformImplementationRef,
353    action: &CFString,
354    attribute: Option<&SecTransformStringOrAttribute>,
355    new_action: SecTransformAttributeActionBlock,
356) -> Option<CFRetained<CFError>> {
357    extern "C-unwind" {
358        fn SecTransformSetAttributeAction(
359            r#ref: SecTransformImplementationRef,
360            action: &CFString,
361            attribute: Option<&SecTransformStringOrAttribute>,
362            new_action: SecTransformAttributeActionBlock,
363        ) -> Option<NonNull<CFError>>;
364    }
365    let ret = unsafe { SecTransformSetAttributeAction(r#ref, action, attribute, new_action) };
366    ret.map(|ret| unsafe { CFRetained::retain(ret) })
367}
368
369/// Change the way a custom transform will do data processing.
370/// When the action parameter is kSecTransformActionProcessData
371/// The newAction block will change the way that input data is
372/// processed to become the output data. When the action
373/// parameter is kSecTransformActionInternalizeExtraData it will
374/// change the way a custom transform reads in data to be
375/// imported into the transform.
376///
377///
378/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
379/// of a custom transform.
380///
381///
382/// Parameter `action`: The action being overridden.  This value should be one of the
383/// following:
384/// kSecTransformActionProcessData
385/// Change the way that input data is processed into the
386/// output data. The default behavior is to simply copy
387/// the input data to the output attribute.
388///
389/// The kSecTransformActionProcessData action is really
390/// a special case of a SecTransformSetAttributeAction
391/// action. If you call this method with
392/// kSecTransformActionProcessData it would overwrite
393/// any kSecTransformActionAttributeNotification action
394/// that was set proviously
395///
396/// kSecTransformActionInternalizeExtraData
397/// Change the way that custom externalized data is
398/// imported into the transform.  The default behavior
399/// is to do nothing.
400///
401///
402/// Parameter `newAction`: A SecTransformDataBlock which implements the behavior.
403///
404/// If the action parameter is kSecTransformActionProcessData then
405/// this block will be called to process the input data into the
406/// output data.
407///
408/// if the action parameter is kSecTransformActionInternalizeExtraData then
409/// this block will called to input custom data into the transform.
410///
411///
412/// Returns: A CFErrorRef is an error occured NULL otherwise.
413///
414///
415/// This API may be called multiple times.  Each time the API is called
416/// it overwrites what was there previously.
417#[cfg(feature = "block2")]
418#[deprecated = "SecTransform is no longer supported"]
419#[inline]
420pub unsafe extern "C-unwind" fn SecTransformSetDataAction(
421    r#ref: SecTransformImplementationRef,
422    action: &CFString,
423    new_action: SecTransformDataBlock,
424) -> Option<CFRetained<CFError>> {
425    extern "C-unwind" {
426        fn SecTransformSetDataAction(
427            r#ref: SecTransformImplementationRef,
428            action: &CFString,
429            new_action: SecTransformDataBlock,
430        ) -> Option<NonNull<CFError>>;
431    }
432    let ret = unsafe { SecTransformSetDataAction(r#ref, action, new_action) };
433    ret.map(|ret| unsafe { CFRetained::retain(ret) })
434}
435
436#[cfg(feature = "block2")]
437#[deprecated = "SecTransform is no longer supported"]
438#[inline]
439pub unsafe extern "C-unwind" fn SecTransformSetTransformAction(
440    r#ref: SecTransformImplementationRef,
441    action: &CFString,
442    new_action: SecTransformActionBlock,
443) -> Option<CFRetained<CFError>> {
444    extern "C-unwind" {
445        fn SecTransformSetTransformAction(
446            r#ref: SecTransformImplementationRef,
447            action: &CFString,
448            new_action: SecTransformActionBlock,
449        ) -> Option<NonNull<CFError>>;
450    }
451    let ret = unsafe { SecTransformSetTransformAction(r#ref, action, new_action) };
452    ret.map(|ret| unsafe { CFRetained::retain(ret) })
453}
454
455/// Allow a custom transform to get an attribute value
456///
457///
458/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
459/// of a custom transform.
460///
461///
462/// Parameter `attribute`: The name or the attribute handle of the attribute whose
463/// value is to be retrieved.
464///
465///
466/// Parameter `type`: The type of data to be retrieved for the attribute.  See the
467/// discussion on SecTransformMetaAttributeType for details.
468///
469///
470/// Returns: The value of the attribute.
471#[deprecated]
472#[inline]
473pub unsafe extern "C-unwind" fn SecTranformCustomGetAttribute(
474    r#ref: SecTransformImplementationRef,
475    attribute: &SecTransformStringOrAttribute,
476    r#type: SecTransformMetaAttributeType,
477) -> Option<CFRetained<CFType>> {
478    extern "C-unwind" {
479        fn SecTranformCustomGetAttribute(
480            r#ref: SecTransformImplementationRef,
481            attribute: &SecTransformStringOrAttribute,
482            r#type: SecTransformMetaAttributeType,
483        ) -> Option<NonNull<CFType>>;
484    }
485    let ret = unsafe { SecTranformCustomGetAttribute(r#ref, attribute, r#type) };
486    ret.map(|ret| unsafe { CFRetained::retain(ret) })
487}
488
489/// Allow a custom transform to get an attribute value
490///
491///
492/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
493/// of a custom transform.
494///
495///
496/// Parameter `attribute`: The name or the attribute handle of the attribute whose
497/// value is to be retrieved.
498///
499///
500/// Parameter `type`: The type of data to be retrieved for the attribute.  See the
501/// discussion on SecTransformMetaAttributeType for details.
502///
503///
504/// Returns: The value of the attribute.
505#[deprecated = "SecTransform is no longer supported"]
506#[inline]
507pub unsafe extern "C-unwind" fn SecTransformCustomGetAttribute(
508    r#ref: SecTransformImplementationRef,
509    attribute: &SecTransformStringOrAttribute,
510    r#type: SecTransformMetaAttributeType,
511) -> Option<CFRetained<CFType>> {
512    extern "C-unwind" {
513        #[link_name = "SecTranformCustomGetAttribute"]
514        fn SecTransformCustomGetAttribute(
515            r#ref: SecTransformImplementationRef,
516            attribute: &SecTransformStringOrAttribute,
517            r#type: SecTransformMetaAttributeType,
518        ) -> Option<NonNull<CFType>>;
519    }
520    let ret = unsafe { SecTransformCustomGetAttribute(r#ref, attribute, r#type) };
521    ret.map(|ret| unsafe { CFRetained::retain(ret) })
522}
523
524/// Allow a custom transform to set an attribute value
525///
526///
527/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
528/// of a custom transform.
529///
530///
531/// Parameter `attribute`: The name or the attribute handle of the attribute whose
532/// value is to be set.
533///
534///
535/// Parameter `type`: The type of data to be retrieved for the attribute.  See the
536/// discussion on SecTransformMetaAttributeType for details.
537///
538///
539/// Parameter `value`: The new value for the attribute
540///
541///
542/// Returns: A CFErrorRef if an error occured , NULL otherwise.
543///
544///
545/// Unlike the SecTransformSetAttribute API this API can set
546/// attribute values while a transform is executing.  These
547/// values are limited to the custom transform instance that
548/// is bound to the ref parameter.
549#[deprecated = "SecTransform is no longer supported"]
550#[inline]
551pub unsafe extern "C-unwind" fn SecTransformCustomSetAttribute(
552    r#ref: SecTransformImplementationRef,
553    attribute: &SecTransformStringOrAttribute,
554    r#type: SecTransformMetaAttributeType,
555    value: Option<&CFType>,
556) -> Option<CFRetained<CFType>> {
557    extern "C-unwind" {
558        fn SecTransformCustomSetAttribute(
559            r#ref: SecTransformImplementationRef,
560            attribute: &SecTransformStringOrAttribute,
561            r#type: SecTransformMetaAttributeType,
562            value: Option<&CFType>,
563        ) -> Option<NonNull<CFType>>;
564    }
565    let ret = unsafe { SecTransformCustomSetAttribute(r#ref, attribute, r#type, value) };
566    ret.map(|ret| unsafe { CFRetained::retain(ret) })
567}
568
569/// Allows for putting a single value back for a specific
570/// attribute.  This will stop the flow of data into the
571/// specified attribute until any attribute is changed for the
572/// transform instance bound to the ref parameter.
573///
574///
575/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
576/// of a custom transform.
577///
578///
579/// Parameter `attribute`: The name or the attribute handle of the attribute whose
580/// value is to be pushed back.
581///
582///
583/// Parameter `value`: The value being pushed back.
584///
585///
586/// Returns: A CFErrorRef if an error occured , NULL otherwise.
587#[deprecated = "SecTransform is no longer supported"]
588#[inline]
589pub unsafe extern "C-unwind" fn SecTransformPushbackAttribute(
590    r#ref: SecTransformImplementationRef,
591    attribute: &SecTransformStringOrAttribute,
592    value: &CFType,
593) -> Option<CFRetained<CFType>> {
594    extern "C-unwind" {
595        fn SecTransformPushbackAttribute(
596            r#ref: SecTransformImplementationRef,
597            attribute: &SecTransformStringOrAttribute,
598            value: &CFType,
599        ) -> Option<NonNull<CFType>>;
600    }
601    let ret = unsafe { SecTransformPushbackAttribute(r#ref, attribute, value) };
602    ret.map(|ret| unsafe { CFRetained::retain(ret) })
603}
604
605/// A function pointer to a function that will create a
606/// new instance of a custom transform.
607///
608///
609/// Parameter `name`: The name of the new custom transform. This name MUST be
610/// unique.
611///
612///
613/// Parameter `newTransform`: The newly created transform Ref.
614///
615///
616/// Parameter `ref`: A reference that is bound to an instance of a custom
617/// transform.
618///
619///
620/// Returns: A SecTransformInstanceBlock that is used to create a new
621/// instance of a custom transform.
622///
623///
624/// The CreateTransform function creates a new transform. The
625/// SecTransformInstanceBlock that is returned from this
626/// function provides the implementation of all of the overrides
627/// necessary to create the custom transform. This returned
628/// SecTransformInstanceBlock is also where the "instance"
629/// variables for the custom transform may be defined. See the
630/// example in the header section of this file for more detail.
631///
632/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformcreatefp?language=objc)
633#[cfg(all(feature = "SecTransform", feature = "block2"))]
634pub type SecTransformCreateFP = Option<
635    unsafe extern "C-unwind" fn(
636        NonNull<CFString>,
637        NonNull<SecTransform>,
638        SecTransformImplementationRef,
639    ) -> SecTransformInstanceBlock,
640>;
641
642extern "C" {
643    /// Overrides the standard behavior that checks to see if all of the
644    /// required attributes either have been set or are connected to
645    /// another transform.  When overriding the default behavior the
646    /// developer can decided what the necessary data is to have for a
647    /// transform to be considered 'ready to run'.  Returning NULL means
648    /// that the transform is ready to be run. If the transform is NOT
649    /// ready to run then the override should return a CFErrorRef
650    /// stipulating the error.
651    ///
652    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactioncanexecute?language=objc)
653    pub static kSecTransformActionCanExecute: &'static CFString;
654}
655
656extern "C" {
657    /// Overrides the standard behavior that occurs just before starting
658    /// execution of a custom transform. This is typically overridden
659    /// to allow for initialization. This is used with the
660    /// SecTransformOverrideTransformAction block.
661    ///
662    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionstartingexecution?language=objc)
663    pub static kSecTransformActionStartingExecution: &'static CFString;
664}
665
666extern "C" {
667    /// Overrides the standard behavior that occurs just before deleting
668    /// a custom transform. This is typically overridden to allow for
669    /// memory clean up of a custom transform.  This is used with the
670    /// SecTransformOverrideTransformAction block.
671    ///
672    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionfinalize?language=objc)
673    pub static kSecTransformActionFinalize: &'static CFString;
674}
675
676extern "C" {
677    /// Allows for adding to the data that is stored using an override
678    /// to the kSecTransformActionExternalizeExtraData block. The output
679    /// of this override is a dictionary that contains the custom
680    /// externalized data. A common use of this override is to write out
681    /// a version number of a custom transform.
682    ///
683    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionexternalizeextradata?language=objc)
684    pub static kSecTransformActionExternalizeExtraData: &'static CFString;
685}
686
687extern "C" {
688    /// Overrides the standard data processing for an attribute. This is
689    /// almost exclusively used for processing the input attribute as
690    /// the return value of their block sets the output attribute. This
691    /// is used with the SecTransformOverrideAttributeAction block.
692    ///
693    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionprocessdata?language=objc)
694    pub static kSecTransformActionProcessData: &'static CFString;
695}
696
697extern "C" {
698    /// Overrides the standard processing that occurs when externalized
699    /// data is used to create a transform.  This is closely tied to the
700    /// kSecTransformActionExternalizeExtraData override. The 'normal'
701    /// attributes are read into the new transform and then this is
702    /// called to read in the items that were written out using
703    /// kSecTransformActionExternalizeExtraData override. A common use
704    /// of this override would be to read in the version number of the
705    /// externalized custom transform.
706    ///
707    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactioninternalizeextradata?language=objc)
708    pub static kSecTransformActionInternalizeExtraData: &'static CFString;
709}
710
711extern "C" {
712    /// Allows a block to be called when an attribute is set.  This
713    /// allows for caching the value as a block variable in the instance
714    /// block or transmogrifying the data to be set. This action is
715    /// where a custom transform would be able to do processing outside
716    /// of processing input to output as process data does.  One the
717    /// data has been processed the action block can call
718    /// SecTransformCustomSetAttribute to update and other attribute.
719    ///
720    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionattributenotification?language=objc)
721    pub static kSecTransformActionAttributeNotification: &'static CFString;
722}
723
724extern "C" {
725    /// Allows a block to be called to validate the new value for an
726    /// attribute.  The default is no validation and any CFTypeRef can
727    /// be used as the new value.  The block should return NULL if the
728    /// value is ok to set on the attribute or a CFErrorRef otherwise.
729    ///
730    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionattributevalidation?language=objc)
731    pub static kSecTransformActionAttributeValidation: &'static CFString;
732}
733
734/// Register a new custom transform so that it may be used to
735/// process data
736///
737///
738/// Parameter `uniqueName`: A unique name for this custom transform.  It is recommended
739/// that a reverse DNS name be used for the name of your custom
740/// transform
741///
742///
743/// Parameter `createTransformFunction`: A SecTransformCreateFP function pointer. The function must
744/// return a SecTransformInstanceBlock block that block_copy has
745/// been called on before returning the block. Failure to call
746/// block_copy will cause undefined behavior.
747///
748///
749/// Parameter `error`: This pointer is set if an error occurred.  This value
750/// may be NULL if you do not want an error returned.
751///
752///
753/// Returns: True if the custom transform was registered false otherwise
754#[cfg(all(feature = "SecTransform", feature = "block2"))]
755#[deprecated = "SecTransform is no longer supported"]
756#[inline]
757pub unsafe extern "C-unwind" fn SecTransformRegister(
758    unique_name: &CFString,
759    create_transform_function: SecTransformCreateFP,
760    error: *mut *mut CFError,
761) -> bool {
762    extern "C-unwind" {
763        fn SecTransformRegister(
764            unique_name: &CFString,
765            create_transform_function: SecTransformCreateFP,
766            error: *mut *mut CFError,
767        ) -> Boolean;
768    }
769    let ret = unsafe { SecTransformRegister(unique_name, create_transform_function, error) };
770    ret != 0
771}
772
773/// Creates a transform computation object.
774///
775///
776/// Parameter `name`: The type of transform to create, must have been registered
777/// by SecTransformRegister, or be a system pre-defined
778/// transform type.
779///
780///
781/// Parameter `error`: A pointer to a CFErrorRef.  This pointer is set if an error
782/// occurred.  This value may be NULL if you do not want an
783/// error returned.
784///
785///
786/// Returns: A pointer to a SecTransformRef object.  This object must be
787/// released with CFRelease when you are done with it.  This
788/// function returns NULL if an error occurred.
789#[cfg(feature = "SecTransform")]
790#[deprecated = "SecTransform is no longer supported"]
791#[inline]
792pub unsafe extern "C-unwind" fn SecTransformCreate(
793    name: &CFString,
794    error: *mut *mut CFError,
795) -> Option<CFRetained<SecTransform>> {
796    extern "C-unwind" {
797        fn SecTransformCreate(
798            name: &CFString,
799            error: *mut *mut CFError,
800        ) -> Option<NonNull<SecTransform>>;
801    }
802    let ret = unsafe { SecTransformCreate(name, error) };
803    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
804}
805
806/// Returns back A CFTypeRef from inside a processData
807/// override that says that while no data is being returned
808/// the transform is still active and awaiting data.
809///
810///
811/// Returns: A 'special' value that allows that specifies that the
812/// transform is still active and awaiting data.
813///
814///
815/// The standard behavior for the ProcessData override is that
816/// it will receive a CFDataRef and it processes that data and
817/// returns a CFDataRef that contains the processed data. When
818/// there is no more data to process the ProcessData override
819/// block is called one last time with a NULL CFDataRef.  The
820/// ProcessData block should/must return the NULL CFDataRef to
821/// complete the processing.  This model does not work well for
822/// some transforms. For example a digest transform needs to see
823/// ALL of the data that is being digested before it can send
824/// out the digest value.
825///
826/// If a ProcessData block has no data to return, it can return
827/// SecTransformNoData(), which informs the transform system
828/// that there is no data to pass on to the next transform.
829#[deprecated = "SecTransform is no longer supported"]
830#[inline]
831pub unsafe extern "C-unwind" fn SecTransformNoData() -> CFRetained<CFType> {
832    extern "C-unwind" {
833        fn SecTransformNoData() -> Option<NonNull<CFType>>;
834    }
835    let ret = unsafe { SecTransformNoData() };
836    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
837    unsafe { CFRetained::retain(ret) }
838}