pairing_blob.h 4.4 KB

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