PVEClass.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. #ifndef _PVE_CLASS_H_
  32. #define _PVE_CLASS_H_
  33. #include "AEClass.h"
  34. #include "aeerror.h"
  35. #include "provision_msg.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 psvn_t* psvn,
  49. const signed_pek_t *pek,
  50. bool performance_rekey_used,
  51. prov_msg1_output_t* output);
  52. uint32_t get_ek2(
  53. const prov_get_ek2_input_t* input,
  54. prov_get_ek2_output_t* ek2);
  55. uint32_t proc_prov_msg2_data(
  56. const proc_prov_msg2_blob_input_t* input,
  57. const uint8_t* sigrl,
  58. uint32_t sigrl_size,
  59. gen_prov_msg3_output_t* msg3_fixed_output,
  60. uint8_t* epid_sig,
  61. uint32_t epid_sig_buffer_size);
  62. uint32_t proc_prov_msg4_data(
  63. const proc_prov_msg4_input_t* msg4_input,
  64. proc_prov_msg4_output_t* data_blob);
  65. public:
  66. uint32_t gen_es_msg1_data(
  67. gen_endpoint_selection_output_t* es_output);
  68. uint32_t gen_prov_msg1(
  69. const psvn_t* psvn,
  70. const signed_pek_t& pek,
  71. bool performance_rekey_used,
  72. uint8_t* msg1,
  73. uint32_t msg1_size);
  74. uint32_t proc_prov_msg2(
  75. const uint8_t* msg2,
  76. uint32_t msg2_size,
  77. const signed_pek_t& pek,
  78. const uint8_t* epid_blob,
  79. uint32_t blob_size,
  80. uint8_t ek2[SK_SIZE],
  81. psvn_t* sigrl_svn,
  82. uint8_t* msg3,
  83. uint32_t msg3_size);
  84. uint32_t proc_prov_msg4(
  85. bool use_ek2_in_input,
  86. const uint8_t ek2[SK_SIZE],
  87. const uint8_t* msg4,
  88. uint32_t msg4_size,
  89. uint8_t* data_blob,
  90. uint32_t blob_size);
  91. uint32_t gen_es_msg1(
  92. uint8_t *msg,
  93. uint32_t msg_size,
  94. const gen_endpoint_selection_output_t& es1_output);
  95. uint32_t proc_es_msg2(
  96. const uint8_t *msg,
  97. uint32_t msg_size,
  98. char server_url[MAX_PATH],
  99. uint16_t& ttl,
  100. const uint8_t xid[XID_SIZE],
  101. uint8_t rsa_signature[PVE_RSA_KEY_BYTES],
  102. signed_pek_t& pek);
  103. };
  104. #endif