xref: /xnu-11215.61.5/EXTERNAL_HEADERS/image4/identifier.h (revision 4f1223e81cd707a65cc109d0b8ad6653699da3c4)
1*4f1223e8SApple OSS Distributions /*
2*4f1223e8SApple OSS Distributions  * Copyright © 2017-2024 Apple Inc. All rights reserved.
3*4f1223e8SApple OSS Distributions  *
4*4f1223e8SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*4f1223e8SApple OSS Distributions  *
6*4f1223e8SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*4f1223e8SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*4f1223e8SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*4f1223e8SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*4f1223e8SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*4f1223e8SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*4f1223e8SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*4f1223e8SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*4f1223e8SApple OSS Distributions  *
15*4f1223e8SApple OSS Distributions  * Please obtain a copy of the License at
16*4f1223e8SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*4f1223e8SApple OSS Distributions  *
18*4f1223e8SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*4f1223e8SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*4f1223e8SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*4f1223e8SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*4f1223e8SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*4f1223e8SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*4f1223e8SApple OSS Distributions  * limitations under the License.
25*4f1223e8SApple OSS Distributions  *
26*4f1223e8SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*4f1223e8SApple OSS Distributions  */
28*4f1223e8SApple OSS Distributions /*!
29*4f1223e8SApple OSS Distributions  * @header
30*4f1223e8SApple OSS Distributions  * Encapsulation which describes an Image4 identifier. An identifier expresses
31*4f1223e8SApple OSS Distributions  * the four character code in a signing request as well as the constraint that
32*4f1223e8SApple OSS Distributions  * the environment places on it.
33*4f1223e8SApple OSS Distributions  *
34*4f1223e8SApple OSS Distributions  * Identifiers are not created directly; they are always provided to the caller
35*4f1223e8SApple OSS Distributions  * by other API and exist within the context of an environment.
36*4f1223e8SApple OSS Distributions  */
37*4f1223e8SApple OSS Distributions #ifndef __IMAGE4_API_IDENTIFIER_H
38*4f1223e8SApple OSS Distributions #define __IMAGE4_API_IDENTIFIER_H
39*4f1223e8SApple OSS Distributions 
40*4f1223e8SApple OSS Distributions #include <image4/image4.h>
41*4f1223e8SApple OSS Distributions #include <image4/types.h>
42*4f1223e8SApple OSS Distributions #include <image4/coprocessor.h>
43*4f1223e8SApple OSS Distributions 
44*4f1223e8SApple OSS Distributions __BEGIN_DECLS
45*4f1223e8SApple OSS Distributions OS_ASSUME_NONNULL_BEGIN
46*4f1223e8SApple OSS Distributions OS_ASSUME_PTR_ABI_SINGLE_BEGIN
47*4f1223e8SApple OSS Distributions 
48*4f1223e8SApple OSS Distributions #pragma mark Types
49*4f1223e8SApple OSS Distributions /*!
50*4f1223e8SApple OSS Distributions  * @typedef image4_identifier_constraint_t
51*4f1223e8SApple OSS Distributions  * An enumeration expressing the type of constraint the identifier places on the
52*4f1223e8SApple OSS Distributions  * environment.
53*4f1223e8SApple OSS Distributions  *
54*4f1223e8SApple OSS Distributions  * @const IMAGE4_IDENTIFIER_CONSTRAINT_EQ
55*4f1223e8SApple OSS Distributions  * The identifier must match the value in the manifest.
56*4f1223e8SApple OSS Distributions  *
57*4f1223e8SApple OSS Distributions  * @const IMAGE4_IDENTIFIER_CONSTRAINT_LT
58*4f1223e8SApple OSS Distributions  * The identifier must be less than the value in the manifest.
59*4f1223e8SApple OSS Distributions  *
60*4f1223e8SApple OSS Distributions  * @const IMAGE4_IDENTIFIER_CONSTRAINT_LE
61*4f1223e8SApple OSS Distributions  * The identifier must be less than or equal to the value in the manifest.
62*4f1223e8SApple OSS Distributions  *
63*4f1223e8SApple OSS Distributions  * @const IMAGE4_IDENTIFIER_CONSTRAINT_GT
64*4f1223e8SApple OSS Distributions  * The identifier must be greater than the value in the manifest.
65*4f1223e8SApple OSS Distributions  *
66*4f1223e8SApple OSS Distributions  * @const IMAGE4_IDENTIFIER_CONSTRAINT_GE
67*4f1223e8SApple OSS Distributions  * The identifier must be greater than or equal the value in the manifest.
68*4f1223e8SApple OSS Distributions  *
69*4f1223e8SApple OSS Distributions  * @const IMAGE4_IDENTIFIER_CONSTRAINT_NE
70*4f1223e8SApple OSS Distributions  * The identifier must not be equal to the value in the manifest.
71*4f1223e8SApple OSS Distributions  *
72*4f1223e8SApple OSS Distributions  * @const IMAGE4_IDENTIFIER_CONSTRAINT_UN
73*4f1223e8SApple OSS Distributions  * The identifier is not constrained at all.
74*4f1223e8SApple OSS Distributions  *
75*4f1223e8SApple OSS Distributions  * @const IMAGE4_IDENTIFIER_CONSTRAINT_NA
76*4f1223e8SApple OSS Distributions  * The identifier's constraints are not known, or the identifier does not
77*4f1223e8SApple OSS Distributions  * represent a constraint.
78*4f1223e8SApple OSS Distributions  */
79*4f1223e8SApple OSS Distributions OS_CLOSED_ENUM(image4_identifier_constraint, uint64_t,
80*4f1223e8SApple OSS Distributions 	IMAGE4_IDENTIFIER_CONSTRAINT_EQ,
81*4f1223e8SApple OSS Distributions 	IMAGE4_IDENTIFIER_CONSTRAINT_LT,
82*4f1223e8SApple OSS Distributions 	IMAGE4_IDENTIFIER_CONSTRAINT_LE,
83*4f1223e8SApple OSS Distributions 	IMAGE4_IDENTIFIER_CONSTRAINT_GT,
84*4f1223e8SApple OSS Distributions 	IMAGE4_IDENTIFIER_CONSTRAINT_GE,
85*4f1223e8SApple OSS Distributions 	IMAGE4_IDENTIFIER_CONSTRAINT_NE,
86*4f1223e8SApple OSS Distributions 	IMAGE4_IDENTIFIER_CONSTRAINT_UN,
87*4f1223e8SApple OSS Distributions 	IMAGE4_IDENTIFIER_CONSTRAINT_NA,
88*4f1223e8SApple OSS Distributions );
89*4f1223e8SApple OSS Distributions 
90*4f1223e8SApple OSS Distributions #pragma mark API
91*4f1223e8SApple OSS Distributions /*!
92*4f1223e8SApple OSS Distributions  * @function image4_identifier_get_constraint
93*4f1223e8SApple OSS Distributions  * Obtain the constraint for the identifier.
94*4f1223e8SApple OSS Distributions  *
95*4f1223e8SApple OSS Distributions  * @param id4
96*4f1223e8SApple OSS Distributions  * The identifier to query.
97*4f1223e8SApple OSS Distributions  *
98*4f1223e8SApple OSS Distributions  * @result
99*4f1223e8SApple OSS Distributions  * The constraint which the environment places on the identifier.
100*4f1223e8SApple OSS Distributions  */
101*4f1223e8SApple OSS Distributions IMAGE4_API_AVAILABLE_SPRING_2024
102*4f1223e8SApple OSS Distributions OS_EXPORT OS_WARN_RESULT OS_NONNULL1
103*4f1223e8SApple OSS Distributions image4_identifier_constraint_t
104*4f1223e8SApple OSS Distributions image4_identifier_get_constraint(const image4_identifier_t *id4);
105*4f1223e8SApple OSS Distributions IMAGE4_XNU_AVAILABLE_DIRECT(image4_identifier_get_constraint);
106*4f1223e8SApple OSS Distributions 
107*4f1223e8SApple OSS Distributions /*!
108*4f1223e8SApple OSS Distributions  * @function image4_identifier_get_constraint
109*4f1223e8SApple OSS Distributions  * Obtain a C string representation of the constraint for the identifier.
110*4f1223e8SApple OSS Distributions  *
111*4f1223e8SApple OSS Distributions  * @param id4
112*4f1223e8SApple OSS Distributions  * The identifier to query.
113*4f1223e8SApple OSS Distributions  *
114*4f1223e8SApple OSS Distributions  * @result
115*4f1223e8SApple OSS Distributions  * The C string representation of the constraint which the identifier places on
116*4f1223e8SApple OSS Distributions  * the environment.
117*4f1223e8SApple OSS Distributions  */
118*4f1223e8SApple OSS Distributions IMAGE4_API_AVAILABLE_SPRING_2024
119*4f1223e8SApple OSS Distributions OS_EXPORT OS_WARN_RESULT OS_NONNULL1
120*4f1223e8SApple OSS Distributions const char *
121*4f1223e8SApple OSS Distributions image4_identifier_get_constraint_cstr(const image4_identifier_t *id4);
122*4f1223e8SApple OSS Distributions IMAGE4_XNU_AVAILABLE_DIRECT(image4_identifier_get_constraint_cstr);
123*4f1223e8SApple OSS Distributions 
124*4f1223e8SApple OSS Distributions /*!
125*4f1223e8SApple OSS Distributions  * @function image4_identifier_get_fourcc
126*4f1223e8SApple OSS Distributions  * Obtain the four character code for the identifier.
127*4f1223e8SApple OSS Distributions  *
128*4f1223e8SApple OSS Distributions  * @param id4
129*4f1223e8SApple OSS Distributions  * The identifier to query.
130*4f1223e8SApple OSS Distributions  *
131*4f1223e8SApple OSS Distributions  * @result
132*4f1223e8SApple OSS Distributions  * The four character code which represents the identifier in a manifest.
133*4f1223e8SApple OSS Distributions  */
134*4f1223e8SApple OSS Distributions IMAGE4_API_AVAILABLE_SPRING_2024
135*4f1223e8SApple OSS Distributions OS_EXPORT OS_WARN_RESULT OS_NONNULL1
136*4f1223e8SApple OSS Distributions uint32_t
137*4f1223e8SApple OSS Distributions image4_identifier_get_fourcc(const image4_identifier_t *id4);
138*4f1223e8SApple OSS Distributions IMAGE4_XNU_AVAILABLE_DIRECT(image4_identifier_get_fourcc);
139*4f1223e8SApple OSS Distributions 
140*4f1223e8SApple OSS Distributions /*!
141*4f1223e8SApple OSS Distributions  * @function image4_identifier_get_fourcc_cstr
142*4f1223e8SApple OSS Distributions  * Obtain the C string representation of the four character code for the
143*4f1223e8SApple OSS Distributions  * identifier.
144*4f1223e8SApple OSS Distributions  *
145*4f1223e8SApple OSS Distributions  * @param id4
146*4f1223e8SApple OSS Distributions  * The identifier to query.
147*4f1223e8SApple OSS Distributions  *
148*4f1223e8SApple OSS Distributions  * @result
149*4f1223e8SApple OSS Distributions  * The C string representation of the four character code which represents the
150*4f1223e8SApple OSS Distributions  * identifier in a manifest.
151*4f1223e8SApple OSS Distributions  */
152*4f1223e8SApple OSS Distributions IMAGE4_API_AVAILABLE_SPRING_2024
153*4f1223e8SApple OSS Distributions OS_EXPORT OS_WARN_RESULT OS_NONNULL1
154*4f1223e8SApple OSS Distributions const char *
155*4f1223e8SApple OSS Distributions image4_identifier_get_fourcc_cstr(const image4_identifier_t *id4);
156*4f1223e8SApple OSS Distributions IMAGE4_XNU_AVAILABLE_DIRECT(image4_identifier_get_fourcc_cstr);
157*4f1223e8SApple OSS Distributions 
158*4f1223e8SApple OSS Distributions OS_ASSUME_PTR_ABI_SINGLE_END
159*4f1223e8SApple OSS Distributions OS_ASSUME_NONNULL_END
160*4f1223e8SApple OSS Distributions __END_DECLS
161*4f1223e8SApple OSS Distributions 
162*4f1223e8SApple OSS Distributions #endif // __IMAGE4_API_IDENTIFIER_H
163