5 #ifndef __IMG4_ENVIRONMENT_H
6 #define __IMG4_ENVIRONMENT_H
8 #ifndef __IMG4_INDIRECT
9 #error "Please #include <img4/img4.h> instead of this file directly"
10 #endif // __IMG4_INDIRECT
17 * @const IMG4_IDENTITY_VERSION
18 * The version of the {@link img4_identity_t} supported by the implementation.
20 #define IMG4_IDENTITY_VERSION (0u)
23 * @const IMG4_ENVIRONMENT_LENGTH
24 * The minimum length for an allocation which can accommodate an
25 * img4_environment_t structure. This is the minimum length which must be given
26 * to {@link img4_environment_init_identity}.
28 #define IMG4_ENVIRONMENT_LENGTH (160ul)
31 * @const IMG4_IDENTITY_CRYPTO_SHA1
32 * The device-tree string indicating that the identity requires SHA1.
34 #define IMG4_IDENTITY_CRYPTO_SHA1 "sha1"
37 * @const IMG4_IDENTITY_CRYPTO_SHA2_384
38 * The device-tree string indicating that the identity requires SHA2-384.
40 #define IMG4_IDENTITY_CRYPTO_SHA2_384 "sha2-384"
43 * @typedef img4_environment_t
44 * An opaque type describing an Image4 environment.
46 typedef struct _img4_environment img4_environment_t
;
49 * @typedef img4_identity_t
50 * A structure describing a specific Image4 identity comprised of user-supplied
54 * The version of the identity structure; initialize to
55 * {@link IMG4_IDENTITY_VERSION}
58 * A string identifying the chosen crypto algorithm as represented in the device
59 * tree. Currently valid values are:
61 * - {@link IMG4_IDENTITY_CRYPTO_SHA1}
62 * - {@link IMG4_IDENTITY_CRYPTO_SHA2_384}
65 * The minimum certificate epoch required,
68 * The board identifier.
71 * The chip identifier.
74 * The unique chip identifier.
77 * The security domain.
80 * The certificate production status.
83 * The certificate security mode.
86 * The effective production status.
89 * The effective security mode.
91 IMG4_API_AVAILABLE_20191001
92 typedef struct _img4_identity
{
93 img4_struct_version_t i4id_version
;
107 * @const IMG4_ENVIRONMENT_PLATFORM
108 * The environment for the host that uses the default platform implementation to
109 * resolve the environment. This is the environment against which manifests are
112 #if !XNU_KERNEL_PRIVATE
113 IMG4_API_AVAILABLE_20180112
115 const struct _img4_environment _img4_environment_platform
;
116 #define IMG4_ENVIRONMENT_PLATFORM (&_img4_environment_platform)
118 #define IMG4_ENVIRONMENT_PLATFORM (img4if->i4if_environment_platform)
123 * @const IMG4_ENVIRONMENT_TRUST_CACHE
124 * The software environment for globally-signed loadable trust caches. This
125 * environment should be used as a fallback when validation against the platform
126 * fails, and the caller is handling a loadable trust cache.
128 #if !XNU_KERNEL_PRIVATE
129 IMG4_API_AVAILABLE_20181004
131 const struct _img4_environment _img4_environment_trust_cache
;
132 #define IMG4_ENVIRONMENT_TRUST_CACHE (&_img4_environment_trust_cache)
134 #define IMG4_ENVIRONMENT_TRUST_CACHE (img4if->i4if_environment_trust_cache)
138 * @function img4_environment_init_identity
139 * Initializes a caller-supplied environment with custom identity information.
140 * This may be used for performing test evaluations or evaluations against
141 * environments not yet supported by the implementation.
144 * A pointer to the storage which will hold the custom environment.
147 * The length of the storage referenced by {@link i4e}. This must be at least
148 * {@link IMG4_ENVIRONMENT_LENGTH} bytes.
151 * The identity with which to initialize the environment. The resulting
152 * environment object will provide these identitifers to the evaluator.
155 * Upon success, zero is returned. The implementation may also return one of the
156 * following error codes directly:
158 * [EOVERFLOW] The length provided is insufficient to initialize an
159 * environment structure
162 * When the resulting environment is given to {@link img4_get_trusted_payload}
163 * or {@link img4_get_trusted_external_payload}, the trust evaluation proceeds
164 * as though it were creating a new chain of trust and therefore acts as though
165 * {@link I4F_FIRST_STAGE} was given to {@link img4_init}. No prior stage of
166 * secure boot will be consulted for evaluation, and mix-n-match will be
167 * presumed to be permitted.
169 #if !XNU_KERNEL_PRIVATE
170 IMG4_API_AVAILABLE_20191001
171 OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL3
173 img4_environment_init_identity(img4_environment_t
*i4e
, size_t len
,
174 const img4_identity_t
*i4id
);
176 #define img4_environment_init_identity(...) \
177 (img4if->i4if_v4.environment_init_identity(__VA_ARGS__))
180 #endif // __IMG4_ENVIRONMENT_H