datatypes.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (C) 2011-2017 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. #include "sgx_report.h"
  32. #include "sgx_eid.h"
  33. #include "sgx_ecp_types.h"
  34. #include "sgx_dh.h"
  35. #include "sgx_tseal.h"
  36. #ifndef DATATYPES_H_
  37. #define DATATYPES_H_
  38. #define DH_KEY_SIZE 20
  39. #define NONCE_SIZE 16
  40. #define MAC_SIZE 16
  41. #define MAC_KEY_SIZE 16
  42. #define PADDING_SIZE 16
  43. #define TAG_SIZE 16
  44. #define IV_SIZE 12
  45. #define DERIVE_MAC_KEY 0x0
  46. #define DERIVE_SESSION_KEY 0x1
  47. #define DERIVE_VK1_KEY 0x3
  48. #define DERIVE_VK2_KEY 0x4
  49. #define CLOSED 0x0
  50. #define IN_PROGRESS 0x1
  51. #define ACTIVE 0x2
  52. #define MESSAGE_EXCHANGE 0x0
  53. #define ENCLAVE_TO_ENCLAVE_CALL 0x1
  54. #define INVALID_ARGUMENT -2 ///< Invalid function argument
  55. #define LOGIC_ERROR -3 ///< Functional logic error
  56. #define FILE_NOT_FOUND -4 ///< File not found
  57. #define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}}
  58. #define VMC_ATTRIBUTE_MASK 0xFFFFFFFFFFFFFFCB
  59. typedef uint8_t dh_nonce[NONCE_SIZE];
  60. typedef uint8_t cmac_128[MAC_SIZE];
  61. #pragma pack(push, 1)
  62. //Format of the AES-GCM message being exchanged between the source and the destination enclaves
  63. typedef struct _secure_message_t
  64. {
  65. uint32_t session_id; //Session ID identifyting the session to which the message belongs
  66. sgx_aes_gcm_data_t message_aes_gcm_data;
  67. }secure_message_t;
  68. //Format of the input function parameter structure
  69. typedef struct _ms_in_msg_exchange_t {
  70. uint32_t msg_type; //Type of Call E2E or general message exchange
  71. uint32_t target_fn_id; //Function Id to be called in Destination. Is valid only when msg_type=ENCLAVE_TO_ENCLAVE_CALL
  72. uint32_t inparam_buff_len; //Length of the serialized input parameters
  73. char inparam_buff[]; //Serialized input parameters
  74. } ms_in_msg_exchange_t;
  75. //Format of the return value and output function parameter structure
  76. typedef struct _ms_out_msg_exchange_t {
  77. uint32_t retval_len; //Length of the return value
  78. uint32_t ret_outparam_buff_len; //Length of the serialized return value and output parameters
  79. char ret_outparam_buff[]; //Serialized return value and output parameters
  80. } ms_out_msg_exchange_t;
  81. //Session Tracker to generate session ids
  82. typedef struct _session_id_tracker_t
  83. {
  84. uint32_t session_id;
  85. }session_id_tracker_t;
  86. #pragma pack(pop)
  87. #endif