aesm_persistent_storage.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. LE_PROD_SIG_STRUCT_FID,
  53. /*some normal persistent storages*/
  54. PROVISION_PEK_BLOB_FID,
  55. EPID_DATA_BLOB_FID,
  56. AESM_SERVER_URL_FID,
  57. /*some special files where pathname could be used directly inside AESM*/
  58. VMC_DATABASE_FID,
  59. VMC_DATABASE_BK_FID,
  60. VMC_DATABASE_PREBUILD_FID,
  61. PSDA_FID,
  62. NETWORK_SETTING_FID,
  63. #ifdef DBG_LOG
  64. AESM_DBG_LOG_FID,
  65. AESM_DBG_LOG_CFG_FID,
  66. #endif
  67. #ifdef _PROFILE_
  68. AESM_PERF_DATA_FID,
  69. #endif
  70. AESM_WHITE_LIST_CERT_FID,
  71. AESM_WHITE_LIST_CERT_TO_BE_VERIFY_FID,
  72. PSE_PR_OCSPRESP_FID,
  73. PSE_PR_LT_PAIRING_FID,
  74. PSE_PR_CERTIFICATE_CHAIN_FID,
  75. PSE_PR_CERTIFICATE_FID,
  76. PSE_PR_CERTIFICATE_FID2,
  77. PSE_PR_CERTIFICATE_FID3,
  78. PSE_PR_CERTIFICATE_FID4,
  79. PSE_PR_CERTIFICATE_FID5,
  80. PSE_PR_CERTIFICATE_FID6,
  81. PSE_PR_CERTIFICATE_FID_MAX,
  82. PSE_PR_FULLNAME_FID,
  83. NUMBER_OF_FIDS
  84. } aesm_data_id_t;
  85. aesm_data_id_t operator++(aesm_data_id_t& id, int);
  86. typedef aesm_data_id_t aesm_enclave_id_t;
  87. /*Function to get pathname of a file object such as vmc database, aesm_get_cpathname is alias of function aesm_get_pathname
  88. *@type: input for the type of the storage
  89. *@data_id: id of persistent storage
  90. *@buf: start address of the buffer to receive the zero terminated path file name of the data
  91. *@buf_size: size in char of the buffer 'buf'
  92. *@return AESM_SUCCESS on success or error code if faileda
  93. */
  94. ae_error_t aesm_get_pathname(aesm_data_type_t type, aesm_data_id_t data_id, char *buf, uint32_t buf_size);
  95. ae_error_t aesm_get_cpathname(aesm_data_type_t type, aesm_data_id_t data_id, char *buf, uint32_t buf_size);
  96. /*Function to query size of data in persistent storage
  97. *@type: input for the type of storage
  98. *@data_id: id of persistent storage
  99. *@p_size: output parameter to return size of the data blob
  100. *@return AESM_SUCCESS on success or error code if failed
  101. */
  102. ae_error_t aesm_query_data_size(aesm_data_type_t type, aesm_data_id_t data_id, uint32_t *p_size);
  103. /*Function to read data from persistent storage
  104. *@type: input type of the storage
  105. *@data_id: id of persistent storage
  106. *@buf: start address of the buffer to receive data from persistent storage
  107. *@p_size: the input value *p_size is size of the buffer and output the size in bytes of data read
  108. *@return AESM_SUCCESS on success or error code if failed
  109. * The functin will not check whether there're too much data in the persistent storage to be read
  110. */
  111. ae_error_t aesm_read_data(aesm_data_type_t type, aesm_data_id_t data_id, uint8_t *buf, uint32_t *p_size);
  112. /*Function to write data to persistent storage
  113. *@type: input type of the storage
  114. *@data_id: id of persistent storage
  115. *@buf: start address of the buffer where the data is to be saved to persistent storage
  116. *@size: size in bytes of the input data in buf
  117. *@return AESM_SUCCESS on success or error code if failed
  118. */
  119. ae_error_t aesm_write_data(aesm_data_type_t type, aesm_data_id_t data_id, const uint8_t *buf, uint32_t size);
  120. #endif