Commit | Line | Data |
---|---|---|
15e8442f JA |
1 | /** |
2 | * @addtogroup MCD_MCDIMPL_DAEMON_REG | |
3 | * @{ | |
4 | * G&D MobiCore Registry Private implementation | |
5 | * | |
6 | * @file | |
7 | * Mobicore Driver Registry. | |
8 | */ | |
9 | ||
cd9434cc | 10 | /* |
15e8442f | 11 | * Copyright (c) 2013 TRUSTONIC LIMITED |
cd9434cc T |
12 | * All rights reserved. |
13 | * | |
14 | * Redistribution and use in source and binary forms, with or without | |
15 | * modification, are permitted provided that the following conditions are met: | |
16 | * | |
17 | * 1. Redistributions of source code must retain the above copyright notice, | |
18 | * this list of conditions and the following disclaimer. | |
19 | * | |
20 | * 2. Redistributions in binary form must reproduce the above copyright | |
21 | * notice, this list of conditions and the following disclaimer in the | |
22 | * documentation and/or other materials provided with the distribution. | |
23 | * | |
24 | * 3. Neither the name of the TRUSTONIC LIMITED nor the names of its | |
25 | * contributors may be used to endorse or promote products derived from | |
26 | * this software without specific prior written permission. | |
27 | * | |
28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
29 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
30 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
31 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | |
32 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
33 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
34 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
35 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
36 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
37 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
38 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
39 | */ | |
40 | #ifndef MOBICORE_REGISTRY_H_ | |
41 | #define MOBICORE_REGISTRY_H_ | |
42 | ||
cd9434cc T |
43 | #include "MobiCoreDriverApi.h" |
44 | #include "mcContainer.h" | |
cd9434cc T |
45 | |
46 | #ifdef __cplusplus | |
47 | extern "C" { | |
48 | #endif | |
cd9434cc | 49 | |
15e8442f JA |
50 | /** |
51 | * Registry object. | |
52 | */ | |
53 | typedef struct { | |
54 | uint32_t len; | |
55 | uint32_t tlStartOffset; | |
56 | uint8_t value[]; | |
57 | } regObject_t; | |
58 | ||
59 | //----------------------------------------------------------------- | |
cd9434cc T |
60 | |
61 | /** Stores an authentication token in registry. | |
62 | * @param so Authentication token secure object. | |
63 | * @param size Authentication token secure object size. | |
64 | * @return MC_DRV_OK if successful, otherwise error code. | |
65 | */ | |
15e8442f | 66 | mcResult_t mcRegistryStoreAuthToken(void *so, uint32_t size); |
cd9434cc T |
67 | |
68 | /** Reads an authentication token from registry. | |
69 | * @param[out] so Authentication token secure object. | |
70 | * @return MC_DRV_OK if successful, otherwise error code. | |
71 | */ | |
72 | mcResult_t mcRegistryReadAuthToken(mcSoAuthTokenCont_t *so); | |
73 | ||
cd9434cc T |
74 | /** Deletes the authentication token secure object from the registry. |
75 | * @return MC_DRV_OK if successful, otherwise error code. | |
76 | */ | |
77 | mcResult_t mcRegistryDeleteAuthToken(void); | |
78 | ||
79 | /** Stores a root container secure object in the registry. | |
80 | * @param so Root container secure object. | |
81 | * @param size Root container secure object size. | |
82 | * @return MC_DRV_OK if successful, otherwise error code. | |
83 | */ | |
15e8442f | 84 | mcResult_t mcRegistryStoreRoot(void *so, uint32_t size); |
cd9434cc T |
85 | |
86 | /** Reads a root container secure object from the registry. | |
87 | * @param[out] so Root container secure object. | |
88 | * @param[out] size Root container secure object size | |
89 | * @return MC_DRV_OK if successful, otherwise error code. | |
90 | */ | |
91 | mcResult_t mcRegistryReadRoot(void *so, uint32_t *size); | |
92 | ||
93 | /** Stores a service provider container secure object in the registry. | |
94 | * @param spid Service provider ID. | |
95 | * @param so Service provider container secure object. | |
96 | * @param size Service provider container secure object size. | |
97 | * @return MC_DRV_OK if successful, otherwise error code. | |
98 | */ | |
15e8442f | 99 | mcResult_t mcRegistryStoreSp(mcSpid_t spid, void *so, uint32_t size); |
cd9434cc T |
100 | |
101 | /** Reads a service provider container secure object from the registry. | |
102 | * @param spid Service provider ID. | |
103 | * @param[out] so Service provider container secure object. | |
104 | * @param[out] size Service provider container secure object size | |
105 | * @return MC_DRV_OK if successful, otherwise error code. | |
106 | */ | |
107 | mcResult_t mcRegistryReadSp(mcSpid_t spid, void *so, uint32_t *size); | |
108 | ||
109 | /** Deletes a service provider recursively, including all trustlets and | |
110 | * data. | |
111 | * @param spid Service provider ID. | |
112 | * @return MC_DRV_OK if successful, otherwise error code. | |
113 | */ | |
114 | mcResult_t mcRegistryCleanupSp(mcSpid_t spid); | |
115 | ||
116 | /** Stores a trustlet container secure object in the registry. | |
117 | * @param uuid Trustlet UUID. | |
118 | * @param so Trustlet container secure object. | |
119 | * @param size Trustlet container secure object size | |
120 | * @return MC_DRV_OK if successful, otherwise error code. | |
121 | */ | |
15e8442f | 122 | mcResult_t mcRegistryStoreTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_t size); |
cd9434cc T |
123 | |
124 | /** Reads a trustlet container secure object from the registry. | |
125 | * @param uuid Trustlet UUID. | |
126 | * @param spid SPID of the trustlet container | |
127 | * @param[out] so Trustlet container secure object. | |
128 | * @param[out] size Trustlet container secure object size | |
129 | * @return MC_DRV_OK if successful, otherwise error code. | |
130 | */ | |
131 | mcResult_t mcRegistryReadTrustletCon(const mcUuid_t *uuid, const mcSpid_t spid, void *so, uint32_t *size); | |
132 | ||
133 | /** Deletes a trustlet container secure object and all of its associated data. | |
134 | * @param uuid Trustlet UUID. | |
135 | * @param spid Service provider ID | |
136 | * @return MC_DRV_OK if successful, otherwise error code. | |
137 | */ | |
138 | mcResult_t mcRegistryCleanupTrustlet(const mcUuid_t *uuid, const mcSpid_t spid); | |
139 | ||
cd9434cc T |
140 | /** Stores a data container secure object in the registry. |
141 | * @param so Data container secure object. | |
142 | * @param size Data container secure object size | |
143 | * @return MC_DRV_OK if successful, otherwise error code. | |
144 | */ | |
15e8442f | 145 | mcResult_t mcRegistryStoreData(void *so, uint32_t size); |
cd9434cc T |
146 | |
147 | /** Reads a data container secure object from the registry. | |
148 | * @param context (service provider = 0; trustlet = 1). | |
149 | * @param cid Service provider or UUID. | |
150 | * @param pid Personalization data identifier. | |
151 | * @param[out] so Data container secure object. | |
152 | * @param maxLen Maximum size (in bytes) of the destination buffer (so). | |
153 | * @return MC_DRV_OK if successful, otherwise error code. | |
154 | */ | |
15e8442f JA |
155 | mcResult_t mcRegistryReadData( |
156 | uint32_t context, | |
157 | const mcCid_t *cid, | |
158 | mcPid_t pid, | |
159 | mcSoDataCont_t *so, | |
160 | uint32_t maxLen); | |
cd9434cc T |
161 | |
162 | /** Deletes the root container and all of its associated service provider | |
163 | * containers. | |
164 | * @return MC_DRV_OK if successful, otherwise error code. | |
165 | */ | |
166 | mcResult_t mcRegistryCleanupRoot(void); | |
167 | ||
15e8442f JA |
168 | /** Returns a registry object for a given service from memory |
169 | * @param spid Service provider ID(ignored for System TLs) | |
170 | * @param trustlet buffer with trustlet binary | |
171 | * @param tlSize buffer size | |
172 | * @return Registry object. | |
173 | * @note It is the responsibility of the caller to free the registry object | |
174 | * allocated by this function. | |
175 | */ | |
176 | regObject_t *mcRegistryMemGetServiceBlob(mcSpid_t spid, void *trustlet, uint32_t tlSize); | |
177 | ||
cd9434cc T |
178 | /** Returns a registry object for a given service. |
179 | * @param uuid service UUID | |
15e8442f JA |
180 | * @return Registry object. |
181 | * @note It is the responsibility of the caller to free the registry object | |
182 | * allocated by this function. | |
183 | */ | |
184 | regObject_t *mcRegistryGetServiceBlob(const mcUuid_t *uuid, bool isGpUuid); | |
185 | ||
186 | /** Returns a registry object for a given service. | |
187 | * @param uuid service GP UUID as mc uuid | |
188 | * @return Registry object. | |
189 | * @note It is the responsibility of the caller to free the registry object | |
190 | * allocated by this function. | |
191 | */ | |
192 | regObject_t *mcRegistryGetServiceBlobGP(const mcUuid_t *uuid); | |
193 | ||
194 | /** Returns a registry object for a given service. | |
195 | * @param driverFilename driver filename | |
196 | * @return Registry object. | |
197 | * @note It is the responsibility of the caller to free the registry object | |
198 | * allocated by this function. | |
cd9434cc | 199 | */ |
15e8442f | 200 | regObject_t *mcRegistryGetDriverBlob(const char *filename); |
cd9434cc T |
201 | |
202 | /** Stores a Trustlet Application blob in the registry. | |
203 | * @param spid SPID of the trustlet container. | |
204 | * @param blob Trustlet Application blob. | |
205 | * @param size Trustlet Application blob size. | |
206 | * @return MC_DRV_OK if successful, otherwise error code. | |
207 | */ | |
15e8442f | 208 | mcResult_t mcRegistryStoreTABlob(mcSpid_t spid, void *blob, uint32_t size); |
cd9434cc T |
209 | |
210 | #ifdef __cplusplus | |
211 | } | |
212 | #endif | |
213 | ||
214 | #endif // MOBICORE_REGISTRY_H_ | |
215 | ||
15e8442f | 216 | /** @} */ |