pairing_blob.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #ifndef _PAIRING_BLOB_H_
  32. #define _PAIRING_BLOB_H_
  33. #include "sgx_tseal.h"
  34. #include "aeerror.h"
  35. #include <stdint.h>
  36. typedef uint8_t UINT8;
  37. typedef uint32_t UINT32;
  38. typedef UINT8 Nonce128_t[16];
  39. typedef UINT32 SHA256_HASH[8];
  40. typedef UINT8 EcDsaPrivKey[32];
  41. typedef UINT8 EcDsaPubKey[64];
  42. typedef UINT8 SIGMA_ID[32];
  43. typedef UINT8 SIGMA_MAC_KEY[16];
  44. typedef UINT8 SIGMA_SECRET_KEY[16];
  45. // BLOB TYPE - Sealblob Type definition is per {MRSIGNER, ProdID} pair
  46. #define PSE_SEAL_PAIRING_BLOB 0
  47. #define PSE_PAIRING_BLOB_VERSION 1
  48. #pragma pack(1)
  49. typedef struct // for SunrisePoint from TaskInfo of SIGMA1.1 message:
  50. {
  51. uint32_t taskId; // byte[ 0- 3] ME_TASK_INFO.TaskID, for SunrisePoint should be 8
  52. uint32_t rsvd1; // byte[ 4- 7] For SKL/GLM time frame, should be 0
  53. uint32_t psdaId; // byte[ 8-11] PSDA ID, mapped from the PSDA Applet ID in ME_TASK_INFO. For SKL/GLM timeframe, should be 1
  54. uint32_t psdaSvn; // byte[12-15] PSDA SVN from ME_TASK_INFO
  55. uint8_t rsvd2[76]; // byte[16-91] Reserved, MBZ
  56. } PS_HW_SEC_INFO;
  57. typedef struct _cse_security_info_t // PS_HW_SEC_PROP_DESC
  58. {
  59. uint32_t ps_hw_sec_info_type; // DESC_TYPE
  60. uint32_t ps_hw_gid; // PS_HW_GID
  61. uint32_t ps_hw_privkey_rlversion; // PS_HW_PrivKey_RLver
  62. uint32_t ps_hw_sig_rlversion; // PS_HW_SIG_RLver
  63. uint8_t ps_hw_CA_id[20]; // PS_HW_CA_ID
  64. PS_HW_SEC_INFO ps_hw_sec_info; // PS_HW_SEC_INFO
  65. } cse_security_info_t;
  66. typedef struct _se_secret_pairing_data_t
  67. {
  68. SHA256_HASH Id_pse;
  69. SHA256_HASH Id_cse;
  70. SIGMA_MAC_KEY mk;
  71. SIGMA_SECRET_KEY sk;
  72. SIGMA_SECRET_KEY pairingID; // old_sk used for repairing check
  73. Nonce128_t pairingNonce;
  74. EcDsaPrivKey VerifierPrivateKey;
  75. } se_secret_pairing_data_t;
  76. typedef struct _se_plaintext_pairing_data_t
  77. {
  78. uint8_t pse_instance_id[16]; // instance id for sigma 1.1 session between pse and csme
  79. uint8_t seal_blob_type; // PSE_SEAL_PAIRING_DATA_BLOB
  80. uint8_t pairing_blob_version; // PSE_PAIRING_DATA_BLOB_VERSION
  81. cse_security_info_t cse_sec_prop;
  82. } se_plaintext_pairing_data_t;
  83. // Pairing blob; only cse_sec_prop is usable outside of enclave
  84. typedef struct _pairing_blob_t
  85. {
  86. struct
  87. {
  88. UINT8 header[sizeof(sgx_sealed_data_t)];
  89. UINT8 encrypted_payload[sizeof(se_secret_pairing_data_t)];
  90. } sealed_pairing_data;
  91. se_plaintext_pairing_data_t plaintext;
  92. } pairing_blob_t;
  93. #define PAIRING_BLOB_PLAINTEXT_OFFSET(pairing_blob_buf) ((reinterpret_cast<sgx_sealed_data_t *>(pairing_blob_buf))->plain_text_offset)
  94. #define PAIRING_BLOB_PLAINTEXT_PTR(pairing_blob_buf) ((reinterpret_cast<se_plaintext_pairing_data_t *>((uint8_t*)pairing_blob_buf) \
  95. + sizeof(sgx_sealed_data_t) + PAIRING_BLOB_PLAINTEXT_OFFSET(pairing_blob_buf))
  96. #pragma pack()
  97. #endif