aesm_persistent_storage.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * Copyright (C) 2011-2016 Intel Corporation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in
  12. * the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Intel Corporation nor the names of its
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. */
  31. #ifndef _AESM_PERSISTENT_STORAGE_H_
  32. #define _AESM_PERSISTENT_STORAGE_H_
  33. #include "aeerror.h"
  34. #include "se_types.h"
  35. /**
  36. * File: aesm_persistent_storage.h
  37. * Description: Definition for interface of persistent storage used in AESM
  38. * Some types and functions are declared
  39. */
  40. typedef enum _aesm_data_type_t{
  41. FT_ENCLAVE_NAME,
  42. FT_PERSISTENT_STORAGE /*putting all files but enclave into persistent storage to simplify the interface*/
  43. } aesm_data_type_t;
  44. /*please refer to persistent_storage_table.cpp for more detail information about persistent storages*/
  45. typedef enum _aesm_data_id_t{
  46. /*first encalve files*/
  47. LE_ENCLAVE_FID,
  48. QE_ENCLAVE_FID,
  49. PVE_ENCLAVE_FID,
  50. PSE_OP_ENCLAVE_FID,
  51. PSE_PR_ENCLAVE_FID,
  52. PCE_ENCLAVE_FID,
  53. LE_PROD_SIG_STRUCT_FID,
  54. /*some normal persistent storages*/
  55. EXTENDED_EPID_GROUP_ID_FID,
  56. EXTENDED_EPID_GROUP_BLOB_INFO_FID,
  57. PROVISION_PEK_BLOB_FID,
  58. EPID_DATA_BLOB_FID,
  59. AESM_SERVER_URL_FID,
  60. /*some special files where pathname could be used directly inside AESM*/
  61. VMC_DATABASE_FID,
  62. VMC_DATABASE_BK_FID,
  63. VMC_DATABASE_PREBUILD_FID,
  64. PSDA_FID,
  65. NETWORK_SETTING_FID,
  66. #ifdef DBG_LOG
  67. AESM_DBG_LOG_FID,
  68. AESM_DBG_LOG_CFG_FID,
  69. #endif
  70. #ifdef _PROFILE_
  71. AESM_PERF_DATA_FID,
  72. #endif
  73. AESM_WHITE_LIST_CERT_FID,
  74. AESM_WHITE_LIST_CERT_TO_BE_VERIFY_FID,
  75. PSE_PR_OCSPRESP_FID,
  76. PSE_PR_LT_PAIRING_FID,
  77. PSE_PR_CERTIFICATE_CHAIN_FID,
  78. PSE_PR_CERTIFICATE_FID,
  79. PSE_PR_CERTIFICATE_FID2,
  80. PSE_PR_CERTIFICATE_FID3,
  81. PSE_PR_CERTIFICATE_FID4,
  82. PSE_PR_CERTIFICATE_FID5,
  83. PSE_PR_CERTIFICATE_FID6,
  84. PSE_PR_CERTIFICATE_FID_MAX,
  85. PSE_PR_FULLNAME_FID,
  86. NUMBER_OF_FIDS
  87. } aesm_data_id_t;
  88. aesm_data_id_t operator++(aesm_data_id_t& id, int);
  89. typedef aesm_data_id_t aesm_enclave_id_t;
  90. #define DEFAULT_EGID 0
  91. #define INVALID_EGID 0xFFFFFFFF
  92. /*Function to get pathname of a file object such as vmc database
  93. *@type: input for the type of the storage
  94. *@data_id: id of persistent storage
  95. *@buf: start address of the buffer to receive the zero terminated path file name of the data
  96. *@buf_size: size in char of the buffer 'buf'
  97. *@xgid: extended epid group id associated with the file if the file location info is AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  98. * the xgid must be INVALID_EGID if the file location info is not AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  99. *@return AESM_SUCCESS on success or error code if failed
  100. */
  101. ae_error_t aesm_get_pathname(aesm_data_type_t type, aesm_data_id_t data_id, char *buf, uint32_t buf_size, uint32_t xgid = INVALID_EGID);
  102. ae_error_t aesm_get_cpathname(aesm_data_type_t type, aesm_data_id_t data_id, char *buf, uint32_t buf_size, uint32_t xgid = INVALID_EGID);
  103. /*Function to query size of data in persistent storage
  104. *@type: input for the type of storage
  105. *@data_id: id of persistent storage
  106. *@p_size: output parameter to return size of the data blob
  107. *@xgid: extended epid group id associated with the file if the file location info is AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  108. * the xgid must be INVALID_EGID if the file location info is not AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  109. *@return AESM_SUCCESS on success or error code if failed
  110. */
  111. ae_error_t aesm_query_data_size(aesm_data_type_t type, aesm_data_id_t data_id, uint32_t *p_size, uint32_t xgid = INVALID_EGID);
  112. /*Function to read data from persistent storage
  113. *@type: input type of the storage
  114. *@data_id: id of persistent storage
  115. *@buf: start address of the buffer to receive data from persistent storage
  116. *@p_size: the input value *p_size is size of the buffer and output the size in bytes of data read
  117. *@xgid: extended epid group id associated with the file if the file location info is AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  118. * the xgid must be INVALID_EGID if the file location info is not AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  119. *@return AESM_SUCCESS on success or error code if failed
  120. * The functin will not check whether there're too much data in the persistent storage to be read
  121. */
  122. ae_error_t aesm_read_data(aesm_data_type_t type, aesm_data_id_t data_id, uint8_t *buf, uint32_t *p_size, uint32_t xgid = INVALID_EGID);
  123. /*Function to write data tp persistent storage
  124. *@type: input type of the storage
  125. *@data_id: id of persistent storage
  126. *@buf: start address of the buffer where the data is to be saved to persistent storage
  127. *@size: size in bytes of the ti be saved
  128. *@xgid: extended epid group id associated with the file if the file location info is AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  129. * the xgid must be INVALID_EGID if the file location info is not AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  130. *@return AESM_SUCCESS on success or error code if failed
  131. * The functin will not check whether there're too much data in the persistent storage to be read
  132. */
  133. ae_error_t aesm_write_data(aesm_data_type_t type, aesm_data_id_t data_id, const uint8_t *buf, uint32_t size, uint32_t xgid = INVALID_EGID);
  134. /*Function to remove data persistent storage
  135. *@type: input type of the storage
  136. *@data_id: id of persistent storage
  137. *@xgid: extended epid group id associated with the file if the file location info is AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  138. * the xgid must be INVALID_EGID if the file location info is not AESM_LOCATION_MULTI_EXTENDED_EPID_GROUP_DATA
  139. *@return AESM_SUCCESS on success or error code if failed
  140. */
  141. ae_error_t aesm_remove_data(aesm_data_type_t type, aesm_data_id_t data_id, uint32_t xgid = INVALID_EGID);
  142. #endif