PVEClass.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 _PVE_CLASS_H_
  32. #define _PVE_CLASS_H_
  33. #include "AEClass.h"
  34. #include "provision_msg.h"
  35. #include "pve_logic.h"
  36. #include "ae_debug_flag.hh"
  37. class CPVEClass: public SingletonEnclave<CPVEClass>
  38. {
  39. friend class Singleton<CPVEClass>;
  40. friend class SingletonEnclave<CPVEClass>;
  41. static aesm_enclave_id_t get_enclave_fid(){return PVE_ENCLAVE_FID;}
  42. protected:
  43. CPVEClass(){};
  44. ~CPVEClass(){};
  45. virtual void before_enclave_load();
  46. virtual int get_debug_flag() { return AE_DEBUG_FLAG;}
  47. uint32_t gen_prov_msg1_data(
  48. const signed_pek_t *pek,
  49. const sgx_target_info_t *pce_target_info,
  50. sgx_report_t *pek_report);
  51. uint32_t proc_prov_msg2_data(
  52. const proc_prov_msg2_blob_input_t* input,
  53. bool performance_rekey_used,
  54. const uint8_t* sigrl,
  55. uint32_t sigrl_size,
  56. gen_prov_msg3_output_t* msg3_fixed_output,
  57. uint8_t* epid_sig,
  58. uint32_t epid_sig_buffer_size);
  59. uint32_t proc_prov_msg4_data(
  60. const proc_prov_msg4_input_t* msg4_input,
  61. proc_prov_msg4_output_t* data_blob);
  62. public:
  63. uint32_t gen_es_msg1_data(
  64. gen_endpoint_selection_output_t* es_output);
  65. uint32_t gen_prov_msg1(pve_data_t& pve_data,
  66. uint8_t* msg1,
  67. uint32_t msg1_size);//input output parameter, input for back_retrieval and output only for other cases
  68. uint32_t proc_prov_msg2(
  69. pve_data_t& data,
  70. const uint8_t* msg2,
  71. uint32_t msg2_size,
  72. const uint8_t* epid_blob,
  73. uint32_t blob_size,
  74. uint8_t* msg3,
  75. uint32_t msg3_size);
  76. uint32_t proc_prov_msg4(
  77. const pve_data_t& data,
  78. const uint8_t* msg4,
  79. uint32_t msg4_size,
  80. uint8_t* data_blob,
  81. uint32_t blob_size);
  82. uint32_t gen_es_msg1(
  83. uint8_t *msg,
  84. uint32_t msg_size,
  85. const gen_endpoint_selection_output_t& es1_output);
  86. uint32_t proc_es_msg2(
  87. const uint8_t *msg,
  88. uint32_t msg_size,
  89. char server_url[MAX_PATH],
  90. uint16_t& ttl,
  91. const uint8_t xid[XID_SIZE],
  92. uint8_t rsa_signature[PVE_RSA_KEY_BYTES],
  93. signed_pek_t& pek);
  94. };
  95. #endif