sgx_tae_service.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (C) 2011-2018 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 _SGX_TAE_SERVICE_H_
  32. #define _SGX_TAE_SERVICE_H_
  33. /**
  34. * File:
  35. * sgx_tae_service.h
  36. *Description:
  37. * header for trusted AE support library.
  38. * ADD from path/sgx_tae_service.edl import *; to your edl file
  39. * to use sgx_tae_service.lib
  40. */
  41. #include "sgx.h"
  42. #include "sgx_defs.h"
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. #pragma pack(push, 1)
  47. typedef uint64_t sgx_time_t;
  48. typedef uint8_t sgx_time_source_nonce_t[32];
  49. #define SGX_MC_UUID_COUNTER_ID_SIZE 3
  50. #define SGX_MC_UUID_NONCE_SIZE 13
  51. typedef struct _mc_uuid {
  52. uint8_t counter_id[SGX_MC_UUID_COUNTER_ID_SIZE];
  53. uint8_t nonce[SGX_MC_UUID_NONCE_SIZE];
  54. } sgx_mc_uuid_t;
  55. /* fixed length to align with internal structure */
  56. typedef struct _ps_sec_prop_desc
  57. {
  58. uint8_t sgx_ps_sec_prop_desc[256];
  59. } sgx_ps_sec_prop_desc_t;
  60. typedef struct _ps_sec_prop_desc_ex
  61. {
  62. sgx_ps_sec_prop_desc_t ps_sec_prop_desc;
  63. sgx_measurement_t pse_mrsigner;
  64. sgx_prod_id_t pse_prod_id;
  65. sgx_isv_svn_t pse_isv_svn;
  66. } sgx_ps_sec_prop_desc_ex_t;
  67. #pragma pack(pop)
  68. /* create a session, call it before using Platform Service */
  69. sgx_status_t SGXAPI sgx_create_pse_session(void);
  70. /* close a created session, call it after finishing using Platform Service */
  71. sgx_status_t SGXAPI sgx_close_pse_session(void);
  72. /* get a data structure describing the Security Property of the Platform Service */
  73. sgx_status_t SGXAPI sgx_get_ps_sec_prop(sgx_ps_sec_prop_desc_t* security_property);
  74. /* get a data structure describing the Security Property of the Platform Service */
  75. sgx_status_t SGXAPI sgx_get_ps_sec_prop_ex(sgx_ps_sec_prop_desc_ex_t* security_property);
  76. /* provides the trusted platform current time */
  77. sgx_status_t SGXAPI sgx_get_trusted_time(
  78. sgx_time_t* current_time,
  79. sgx_time_source_nonce_t* time_source_nonce
  80. );
  81. /* monotonic counter policy */
  82. #define SGX_MC_POLICY_SIGNER 0x1
  83. #define SGX_MC_POLICY_ENCLAVE 0x2
  84. /* create a monotonic counter using given policy(SIGNER 0x1 or ENCLAVE 0x2) and attribute_mask */
  85. sgx_status_t SGXAPI sgx_create_monotonic_counter_ex(
  86. uint16_t owner_policy,
  87. const sgx_attributes_t* owner_attribute_mask,
  88. sgx_mc_uuid_t* counter_uuid,
  89. uint32_t* counter_value
  90. );
  91. /* create a monotonic counter using default policy SIGNER and default attribute_mask */
  92. sgx_status_t SGXAPI sgx_create_monotonic_counter(
  93. sgx_mc_uuid_t* counter_uuid,
  94. uint32_t* counter_value
  95. );
  96. /* destroy a specified monotonic counter */
  97. sgx_status_t SGXAPI sgx_destroy_monotonic_counter(const sgx_mc_uuid_t* counter_uuid);
  98. /* increment a specified monotonic counter by 1 */
  99. sgx_status_t SGXAPI sgx_increment_monotonic_counter(
  100. const sgx_mc_uuid_t* counter_uuid,
  101. uint32_t* counter_value
  102. );
  103. /* read a specified monotonic counter */
  104. sgx_status_t SGXAPI sgx_read_monotonic_counter(
  105. const sgx_mc_uuid_t* counter_uuid,
  106. uint32_t* counter_value
  107. );
  108. #ifdef __cplusplus
  109. }
  110. #endif
  111. #endif