sgx_tae_service.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 _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. #pragma pack(pop)
  61. /* create a session, call it before using Platform Service */
  62. sgx_status_t SGXAPI sgx_create_pse_session(void);
  63. /* close a created session, call it after finishing using Platform Service */
  64. sgx_status_t SGXAPI sgx_close_pse_session(void);
  65. /* get a data structure describing the Security Property of the Platform Service */
  66. sgx_status_t SGXAPI sgx_get_ps_sec_prop(sgx_ps_sec_prop_desc_t* security_property);
  67. /* provides the trusted platform current time */
  68. sgx_status_t SGXAPI sgx_get_trusted_time(
  69. sgx_time_t* current_time,
  70. sgx_time_source_nonce_t* time_source_nonce
  71. );
  72. /* monotonic counter policy */
  73. #define SGX_MC_POLICY_SIGNER 0x1
  74. #define SGX_MC_POLICY_ENCLAVE 0x2
  75. /* create a monotonic counter using given policy(SIGNER 0x1 or ENCLAVE 0x2) and attribute_mask */
  76. sgx_status_t SGXAPI sgx_create_monotonic_counter_ex(
  77. uint16_t owner_policy,
  78. const sgx_attributes_t* owner_attribute_mask,
  79. sgx_mc_uuid_t* counter_uuid,
  80. uint32_t* counter_value
  81. );
  82. /* create a monotonic counter using default policy SIGNER and default attribute_mask */
  83. sgx_status_t SGXAPI sgx_create_monotonic_counter(
  84. sgx_mc_uuid_t* counter_uuid,
  85. uint32_t* counter_value
  86. );
  87. /* destroy a specified monotonic counter */
  88. sgx_status_t SGXAPI sgx_destroy_monotonic_counter(const sgx_mc_uuid_t* counter_uuid);
  89. /* increment a specified monotonic counter by 1 */
  90. sgx_status_t SGXAPI sgx_increment_monotonic_counter(
  91. const sgx_mc_uuid_t* counter_uuid,
  92. uint32_t* counter_value
  93. );
  94. /* read a specified monotonic counter */
  95. sgx_status_t SGXAPI sgx_read_monotonic_counter(
  96. const sgx_mc_uuid_t* counter_uuid,
  97. uint32_t* counter_value
  98. );
  99. #ifdef __cplusplus
  100. }
  101. #endif
  102. #endif