epid_pve_type.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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: epid_pve_type.h
  33. * Description: Header file to declare common types used in pve trust/untrusted code
  34. */
  35. #ifndef _EPID_PVE_TYPE_H_
  36. #define _EPID_PVE_TYPE_H_
  37. #include "epid_types.h"
  38. #include "se_types.h"
  39. #include "sgx_key.h"
  40. /*Some basic macro definition*/
  41. #define EPID_VERSION_MAJOR 2
  42. #define EPID_VERSION_MINOR 0
  43. #define EPID_TYPE_GROUP_CERT 12
  44. #define IV_SIZE 12 /*length in bytes of iv in block cipher. */
  45. #define SK_SIZE 16 /*length in bytes of SK, which is used in block cipher info*/
  46. #define GID_SIZE sizeof(GroupID) /*length in bytes of GroupID*/
  47. #define SK_CMAC_KEY_LEN IppsRijndaelKey128
  48. #define XID_SIZE 8 /*length in bytes of transaction id*/
  49. #define NONCE_SIZE 8 /*length in bytes of Nonce R in ProvMsg*/
  50. #define CHALLENGE_NONCE_SIZE 32 /*length in bytes of Challenge nonce in ProvMsg2*/
  51. #define PPID_SIZE sizeof(ppid_t) /*16*/
  52. #define PSVN_SIZE sizeof(psvn_t) /*18*/
  53. #define FMSP_SIZE sizeof(fmsp_t) /*4*/
  54. #define FLAGS_SIZE sizeof(flags_t) /*256*/
  55. #define MAC_SIZE 16 /*length in bytes of the tag in output of AES-GCM*/
  56. #define PSID_SIZE sizeof(psid_t) /*64*/
  57. #define JOIN_PROOF_SIZE sizeof(JoinRequest)
  58. #define BLIND_ESCROW_SIZE sizeof(blind_escrow_data_t)
  59. #define EPID_KEY_MEMBER_SIZE 16 /*the length in bytes of X,A,F in private key*/
  60. #define PEK_PUB ((uint8_t)0)
  61. #define PEK_PRIV ((uint8_t)1)
  62. #define PWK_KEY ((uint8_t)2)
  63. #define ECDSA_SIGN_SIZE 32 /*This is the size of biginteger for ECDSA signature appended at the end of SIG-RL and the total signature size is size of two such kind of integer*/
  64. #define PVE_RSA_KEY_BITS 2048
  65. #define PVE_RSA_KEY_BYTES (PVE_RSA_KEY_BITS/8)
  66. #pragma pack(1)
  67. /*Define some structure will be used in TLV payload. Make sure the alignment of all of them is 1 since they'll be used in an unaligned buffer
  68. type for Platform Provisioning Identifier, it could be calculated inside PvE*/
  69. typedef struct _ppid_t{
  70. uint8_t ppid[16];
  71. }ppid_t;
  72. typedef struct _fmsp_t{
  73. uint8_t fmsp[4];
  74. }fmsp_t;
  75. /*type for provisioning server Identifier, the hash of provisioning server public key*/
  76. typedef struct _psid_t{
  77. uint8_t psid[32];
  78. }psid_t;
  79. /*type for Platform Security Version Numbers. Data structure without alignment required. */
  80. typedef struct _psvn_t{
  81. sgx_cpu_svn_t cpu_svn;
  82. sgx_isv_svn_t isv_svn; //PvE SVN
  83. }psvn_t;
  84. /*type for the optional Flags in ProvMsg1. Currently only the 1st bit is defined for performance rekey flag*/
  85. typedef struct _flags_t{
  86. uint8_t flags[16];
  87. }flags_t;
  88. /*type for EpidVersion used in Epid Data which is two bytes big endian integer*/
  89. typedef struct _epid_version_t{
  90. uint8_t data[2];
  91. }epid_version_t;
  92. /*type for EpidType used in Epid Data which is two bytes big endian integer*/
  93. typedef struct _epid_type_t{
  94. uint8_t data[2];
  95. }epid_type_t;
  96. /*Type for Epid Group Public Cert*/
  97. typedef struct _signed_epid_group_cert_t{
  98. epid_version_t version;
  99. epid_type_t type;
  100. GroupPubKey key;
  101. uint8_t intel_signature[2*ECDSA_SIGN_SIZE];
  102. }signed_epid_group_cert_t;
  103. typedef struct _signed_pek_t{
  104. uint8_t n[256];
  105. uint8_t e[4];
  106. uint8_t sha1_ne[20];
  107. uint8_t pek_signature[2*ECDSA_SIGN_SIZE];
  108. uint8_t sha1_sign[20];
  109. }signed_pek_t;
  110. /*Type for an Blind Escrow Data which is used in provisioning message 3 and message 4.
  111. The data structure is only used by PvE*/
  112. typedef struct _blind_escrow_data_t{
  113. uint32_t version;
  114. uint8_t iv[IV_SIZE];
  115. PElemStr f;
  116. uint8_t mac[MAC_SIZE];
  117. }blind_escrow_data_t;
  118. /*The Join Proof with Escrow data in provisioning message 3*/
  119. typedef struct _join_proof_with_escrow_t{
  120. JoinRequest jr;
  121. blind_escrow_data_t escrow;
  122. }join_proof_with_escrow_t;
  123. /*The Membership Credential with Escrow Data used in provisioning message 4*/
  124. typedef struct _membertship_credential_with_escrow_t{
  125. PElemStr x;
  126. G1ElemStr A;
  127. blind_escrow_data_t escrow;
  128. }membertship_credential_with_escrow_t;
  129. /*The Device ID structure used in Provisioning message*/
  130. typedef struct _device_id_t{
  131. ppid_t ppid;
  132. psvn_t psvn;
  133. fmsp_t fmsp;
  134. }device_id_t;
  135. #define EPID_KEY_BLOB_VERSION 1
  136. #define PVE_SEAL_EPID_KEY_BLOB 0
  137. #pragma pack(push, 1)
  138. typedef struct _se_secret_epid_data_t {
  139. PrivKey epid_private_key;
  140. }se_secret_epid_data_t;
  141. typedef struct _se_plaintext_epid_data_t {
  142. uint8_t seal_blob_type; /*Encalve-specific Sealblob Type, for 2015 PvE/QE, only one Sealblob type defined: PVE_SEAL_EPID_KEY_BLOB=0*/
  143. uint8_t epid_key_version;/*epid key version should be EPID_KEY_BLOB_VERSION=1*/
  144. sgx_cpu_svn_t equiv_cpu_svn;
  145. sgx_isv_svn_t equiv_isv_svn;
  146. EPID2Params epid_param_cert;
  147. GroupPubKey epid_group_cert;
  148. }se_plaintext_epid_data_t;
  149. #pragma pack(pop)
  150. #define SGX_TRUSTED_EPID_BLOB_SIZE (sgx_calc_sealed_data_size( \
  151. sizeof(se_plaintext_epid_data_t), \
  152. sizeof(se_secret_epid_data_t)))
  153. #pragma pack()
  154. #endif