tlv_common.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. /**
  32. * File: tlv_common.h
  33. * Description: Header file to define TLV (the Type Length Value) related data or structure which may be commonly used by multiple components
  34. */
  35. #ifndef _PVE_TLV_COMMON_H
  36. #define _PVE_TLV_COMMON_H
  37. #include "se_cdefs.h"
  38. #include "se_types.h"
  39. #include "sgx_key.h"
  40. #include "byte_order.h"
  41. /*enumerate all tlv types, the value of it is not defined in spec yet*/
  42. typedef enum _tlv_enum_type_t{
  43. TLV_CIPHER_TEXT=0,
  44. TLV_BLOCK_CIPHER_TEXT,
  45. TLV_BLOCK_CIPHER_INFO,
  46. TLV_MESSAGE_AUTHENTICATION_CODE,
  47. TLV_NONCE,
  48. TLV_EPID_GID,
  49. TLV_EPID_SIG_RL,
  50. TLV_EPID_GROUP_CERT,
  51. /*SE Provisioning Protocol TLVs*/
  52. TLV_DEVICE_ID,
  53. TLV_PS_ID,
  54. TLV_EPID_JOIN_PROOF,
  55. TLV_EPID_SIG,
  56. TLV_EPID_MEMBERSHIP_CREDENTIAL,
  57. TLV_EPID_PSVN,
  58. /*PSE Provisioning Protocol TLVs*/
  59. TLV_QUOTE,
  60. TLV_X509_CERT_TLV,
  61. TLV_X509_CSR_TLV,
  62. /*End-point Selection Protocol TLVs*/
  63. TLV_ES_SELECTOR,
  64. TLV_ES_INFORMATION,
  65. /* EPID Provisioning Protocol TLVs Part 2*/
  66. TLV_FLAGS,
  67. /* PSE Quote Signature*/
  68. TLV_QUOTE_SIG,
  69. TLV_PLATFORM_INFO_BLOB,
  70. /* Generic TLVs*/
  71. TLV_SIGNATURE,
  72. /* End-point Selection Protocol TLVs*/
  73. TLV_PEK,
  74. }tlv_enum_type_t;
  75. /*here comes general type and macro definition for AESM related Server URL which will be shared by code in other components*/
  76. typedef enum _aesm_network_server_enum_type_t{
  77. SE_EPID_PROVISIONING,
  78. PSE_PROVISIONING,
  79. ENDPOINT_SELECTION,
  80. REVOCATION_LIST_RETRIEVAL,
  81. PSE_OCSP
  82. }aesm_network_server_enum_type_t;
  83. typedef enum _pve_msg_type_t
  84. {
  85. TYPE_PROV_MSG1,
  86. TYPE_PROV_MSG2,
  87. TYPE_PROV_MSG3,
  88. TYPE_PROV_MSG4
  89. }pve_msg_type_t;
  90. typedef enum _pse_msg_type_t
  91. {
  92. TYPE_PSE_MSG1,
  93. TYPE_PSE_MSG2,
  94. TYPE_PSE_MSG3,
  95. TYPE_PSE_MSG4
  96. }pse_msg_type_t;
  97. typedef enum _es_msg_type_t
  98. {
  99. TYPE_ES_MSG1,
  100. TYPE_ES_MSG2
  101. }es_msg_type_t;
  102. typedef enum _rlr_msg_type_t
  103. {
  104. TYPE_RLR_MSG1,
  105. TYPE_RLR_MSG2
  106. }rlr_msg_type_t;
  107. #include "epid_pve_type.h"
  108. typedef uint16_t general_response_status_t;
  109. enum _general_response_status_t
  110. {
  111. GRS_OK,
  112. GRS_SERVER_BUSY,
  113. GRS_INTEGRITY_CHECK_FAIL,
  114. GRS_INCORRECT_SYNTAX,
  115. GRS_INCOMPATIBLE_VERSION,
  116. GRS_TRANSACTION_STATE_LOST,
  117. GRS_PROTOCOL_ERROR,
  118. GRS_INTERNAL_ERROR
  119. };
  120. typedef uint16_t se_protocol_response_status_t;
  121. enum _se_protocol_response_status_t
  122. {
  123. SE_PRS_OK,
  124. SE_PRS_PLATFORM_REVOKED,
  125. SE_PRS_STATUS_INTEGRITY_FAILED,
  126. SE_PRS_PERFORMANCE_REKEY_NOT_SUPPORTED
  127. };
  128. typedef uint16_t pse_protocol_response_status_t;
  129. enum _pse_protocol_response_status_t
  130. {
  131. PSE_PRS_OK,
  132. PSE_PRS_INVALID_GID,
  133. PSE_PRS_GID_REVOKED,
  134. PSE_PRS_INVALID_QUOTE,
  135. PSE_PRS_INVALID_REQUEST
  136. };
  137. #pragma pack(1)
  138. #define NET_S_OK 0
  139. typedef struct _provision_request_header_t{
  140. uint8_t protocol;
  141. uint8_t version;
  142. uint8_t xid[XID_SIZE]; /*transaction id, the unique id from ProvMsg1 to ProvMsg4*/
  143. uint8_t type;
  144. uint8_t size[4]; /*size of request body*/
  145. }provision_request_header_t;
  146. typedef struct _provision_response_header_t{
  147. uint8_t protocol;
  148. uint8_t version;
  149. uint8_t xid[XID_SIZE];
  150. uint8_t type;
  151. uint8_t gstatus[2];
  152. uint8_t pstatus[2];
  153. uint8_t size[4];
  154. }provision_response_header_t;
  155. #pragma pack()
  156. #define PROVISION_REQUEST_HEADER_SIZE sizeof(provision_request_header_t)
  157. #define PROVISION_RESPONSE_HEADER_SIZE sizeof(provision_response_header_t)
  158. #define GET_BODY_SIZE_FROM_PROVISION_REQUEST(req) lv_ntohl(((const provision_request_header_t *)(req))->size)
  159. #define GET_BODY_SIZE_FROM_PROVISION_RESPONSE(resp) lv_ntohl(((const provision_response_header_t *)(resp))->size)
  160. #define GET_SIZE_FROM_PROVISION_REQUEST(req) (GET_BODY_SIZE_FROM_PROVISION_REQUEST(req)+PROVISION_REQUEST_HEADER_SIZE)
  161. #define GET_SIZE_FROM_PROVISION_RESPONSE(resp) (GET_BODY_SIZE_FROM_PROVISION_RESPONSE(resp)+PROVISION_RESPONSE_HEADER_SIZE)
  162. #define GET_TYPE_FROM_PROVISION_REQUEST(req) (((const provision_request_header_t *)(req))->type)
  163. #define GET_TYPE_FROM_PROVISION_RESPONSE(resp) (((const provision_response_header_t *)(resp))->type)
  164. #define TLV_VERSION_1 1
  165. #endif