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