sgx_tkey_exchange.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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_TKEY_EXCHANGE_H_
  32. #define _SGX_TKEY_EXCHANGE_H_
  33. #include "sgx.h"
  34. #include "sgx_defs.h"
  35. #include "sgx_key_exchange.h"
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. /*
  40. * The sgx_ra_init function creates a context for the remote attestation and
  41. * key exchange process.
  42. *
  43. * @param p_pub_key The EC public key of the service provider based on the NIST
  44. * P-256 elliptic curve.
  45. * @param b_pse If true, platform service information is needed in message
  46. * 3. The caller should make sure a PSE session has been
  47. * established using sgx_create_pse_session before attempting
  48. * to establish a remote attestation and key exchange session
  49. * involving platform service information.
  50. * @param p_context The output context for the subsequent remote attestation
  51. * and key exchange process, to be used in sgx_ra_get_msg1 and
  52. * sgx_ra_proc_msg2.
  53. * @return sgx_status_t SGX_SUCCESS Indicates success.
  54. * SGX_ERROR_INVALID_PARAMETER Indicates an error that
  55. * the input parameters are
  56. * invalid.
  57. * SGX_ERROR_KDF_MISMATCH Indicates key derivation
  58. * function doesn't match.
  59. * SGX_ERROR_OUT_OF_MEMORY There is not enough
  60. * memory available to
  61. * complete this operation.
  62. * SGX_ERROR_AE_SESSION_INVALID Session is invalid or
  63. * ended by server.
  64. * SGX_ERROR_UNEXPECTED Indicates an unexpected
  65. * error occurs.
  66. */
  67. sgx_status_t SGXAPI sgx_ra_init(
  68. const sgx_ec256_public_t *p_pub_key,
  69. int b_pse,
  70. sgx_ra_context_t *p_context);
  71. /*
  72. * The sgx_ra_get_keys function is used to get the negotiated keys of a remote
  73. * attestation and key exchange session. This function should only be called
  74. * after the service provider accepts the remote attestation and key exchange
  75. * protocol message 3 produced by sgx_ra_proc_msg2.
  76. *
  77. * @param context Context returned by sgx_ra_init.
  78. * @param type The specifier of keys, can be SGX_RA_KEY_MK, SGX_RA_KEY_SK
  79. * and SGX_RA_VK.
  80. * @param p_key The key returned.
  81. * @return sgx_status_t SGX_SUCCESS Indicates success.
  82. * SGX_ERROR_INVALID_PARAMETER Indicates an error that
  83. * the input parameters are
  84. * invalid.
  85. * SGX_ERROR_INVALID_STATE Indicates this function
  86. * is called out of order.
  87. */
  88. sgx_status_t SGXAPI sgx_ra_get_keys(
  89. sgx_ra_context_t context,
  90. sgx_ra_key_type_t type,
  91. sgx_ra_key_128_t *p_key);
  92. /*
  93. * Call the sgx_ra_close function to release the remote attestation and key
  94. * exchange context after the process is done and the context isn't needed
  95. * anymore.
  96. *
  97. * @param context Context returned by sgx_ra_init.
  98. * @return sgx_status_t SGX_SUCCESS Indicates success.
  99. * SGX_ERROR_INVALID_PARAMETER Indicates an error that
  100. * the input parameters are
  101. * invalid.
  102. */
  103. sgx_status_t SGXAPI sgx_ra_close(
  104. sgx_ra_context_t context);
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif