quoting_sim.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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. #include <stdlib.h>
  32. #include "uae_service_sim.h"
  33. #include "epid/common/types.h"
  34. #include "se_sig_rl.h"
  35. #include "se_quote_internal.h"
  36. #include "ippcp.h"
  37. #include "deriv.h"
  38. #include "cpusvn_util.h"
  39. /* The EPID group certificate */
  40. static const uint8_t EPID_GROUP_CERT[] = {
  41. 0x00, 0x00, 0x00, 0x0B, 0xB3, 0x6F, 0xFF, 0x81, 0xE2, 0x1B, 0x17, 0xEB,
  42. 0x3D, 0x75, 0x3D, 0x61, 0x7E, 0x27, 0xB0, 0xCB, 0xD0, 0x6D, 0x8F, 0x9D,
  43. 0x64, 0xCE, 0xE3, 0xCE, 0x43, 0x4C, 0x62, 0xFD, 0xB5, 0x80, 0xE0, 0x99,
  44. 0x3A, 0x07, 0x56, 0x80, 0xE0, 0x88, 0x59, 0xA4, 0xFD, 0xB5, 0xB7, 0x9D,
  45. 0xE9, 0x4D, 0xAE, 0x9C, 0xEE, 0x3D, 0x66, 0x42, 0x82, 0x45, 0x7E, 0x7F,
  46. 0xD8, 0x69, 0x3E, 0xA1, 0x74, 0xF4, 0x59, 0xEE, 0xD2, 0x74, 0x2E, 0x9F,
  47. 0x63, 0xC2, 0x51, 0x8E, 0xD5, 0xDB, 0xCA, 0x1C, 0x54, 0x74, 0x10, 0x7B,
  48. 0xDC, 0x99, 0xED, 0x42, 0xD5, 0x5B, 0xA7, 0x04, 0x29, 0x66, 0x61, 0x63,
  49. 0xBC, 0xDD, 0x7F, 0xE1, 0x76, 0x5D, 0xC0, 0x6E, 0xE3, 0x14, 0xAC, 0x72,
  50. 0x48, 0x12, 0x0A, 0xA6, 0xE8, 0x5B, 0x08, 0x7B, 0xDA, 0x3F, 0x51, 0x7D,
  51. 0xDE, 0x4C, 0xEA, 0xCB, 0x93, 0xA5, 0x6E, 0xCC, 0xE7, 0x8E, 0x10, 0x84,
  52. 0xBD, 0x19, 0x5A, 0x95, 0xE2, 0x0F, 0xCA, 0x1C, 0x50, 0x71, 0x94, 0x51,
  53. 0x40, 0x1B, 0xA5, 0xB6, 0x78, 0x87, 0x53, 0xF6, 0x6A, 0x95, 0xCA, 0xC6,
  54. 0x8D, 0xCD, 0x36, 0x88, 0x07, 0x28, 0xE8, 0x96, 0xCA, 0x78, 0x11, 0x5B,
  55. 0xB8, 0x6A, 0xE7, 0xE5, 0xA6, 0x65, 0x7A, 0x68, 0x15, 0xD7, 0x75, 0xF8,
  56. 0x24, 0x14, 0xCF, 0xD1, 0x0F, 0x6C, 0x56, 0xF5, 0x22, 0xD9, 0xFD, 0xE0,
  57. 0xE2, 0xF4, 0xB3, 0xA1, 0x90, 0x21, 0xA7, 0xE0, 0xE8, 0xB3, 0xC7, 0x25,
  58. 0xBC, 0x07, 0x72, 0x30, 0x5D, 0xEE, 0xF5, 0x6A, 0x89, 0x88, 0x46, 0xDD,
  59. 0x89, 0xC2, 0x39, 0x9C, 0x0A, 0x3B, 0x58, 0x96, 0x57, 0xE4, 0xF3, 0x3C,
  60. 0x79, 0x51, 0x69, 0x36, 0x1B, 0xB6, 0xF7, 0x05, 0x5D, 0x0A, 0x88, 0xDB,
  61. 0x1F, 0x3D, 0xEA, 0xA2, 0xBA, 0x6B, 0xF0, 0xDA, 0x8E, 0x25, 0xC6, 0xAD,
  62. 0x83, 0x7D, 0x3E, 0x31, 0xEE, 0x11, 0x40, 0xA9
  63. };
  64. /* The report key is the same as BASE_REPORT_KEY in
  65. /trunk/sdk/simulation/tinst/deriv.cpp, which is used in simulation
  66. create_report and verify_report. deriv.cpp is used inside enclave.
  67. So only import this structure. */
  68. static const uint8_t BASE_REPORT_KEY[] = {
  69. 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00,
  70. 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00,
  71. };
  72. // The hard-coded OwnerEpoch.
  73. static const se_owner_epoch_t SIMU_OWNER_EPOCH_MSR = {
  74. 0x54, 0x48, 0x49, 0x53, 0x49, 0x53, 0x4f, 0x57,
  75. 0x4e, 0x45, 0x52, 0x45, 0x50, 0x4f, 0x43, 0x48,
  76. };
  77. //simulated QE ISVSVN
  78. static const sgx_isv_svn_t QE_ISVSVN = 1;
  79. #if !defined(ntohl)
  80. #define ntohl(u32) \
  81. ((uint32_t)(((((unsigned char*)&(u32))[0]) << 24) \
  82. + ((((unsigned char*)&(u32))[1]) << 16) \
  83. + ((((unsigned char*)&(u32))[2]) << 8) \
  84. + (((unsigned char*)&(u32))[3])))
  85. #endif
  86. sgx_status_t sgx_init_quote(
  87. sgx_target_info_t *p_target_info,
  88. sgx_epid_group_id_t *p_gid)
  89. {
  90. if(!p_target_info || !p_gid){
  91. return SGX_ERROR_INVALID_PARAMETER;
  92. }
  93. p_target_info->attributes.flags = SGX_FLAGS_INITTED;
  94. p_target_info->attributes.xfrm = SGX_XFRM_LEGACY;
  95. memset(&(p_target_info->mr_enclave), 0xEE, sizeof(sgx_measurement_t));
  96. //Make sure the size of prebuilt data are the same with target buffer.
  97. se_static_assert(sizeof(EPID_GROUP_CERT) == sizeof(GroupPubKey)); /* "Group cert size changed*/
  98. //Copy hard coded gid into output buffer.
  99. GroupPubKey *p_epid_group_cert = (GroupPubKey *)const_cast<uint8_t*>(EPID_GROUP_CERT);
  100. ((uint8_t *)p_gid)[0] = p_epid_group_cert->gid.data[3];
  101. ((uint8_t *)p_gid)[1] = p_epid_group_cert->gid.data[2];
  102. ((uint8_t *)p_gid)[2] = p_epid_group_cert->gid.data[1];
  103. ((uint8_t *)p_gid)[3] = p_epid_group_cert->gid.data[0];
  104. return SGX_SUCCESS;
  105. }
  106. static sgx_status_t create_qe_report(const sgx_report_t *p_report,
  107. const sgx_quote_nonce_t* p_quote_nonce,
  108. const uint8_t* p_quote,
  109. uint32_t quote_size,
  110. const sgx_cpu_svn_t* cpusvn,
  111. sgx_report_t *p_qe_report)
  112. {
  113. sgx_report_t temp_qe_report;
  114. // assemble REPORT
  115. memset(&temp_qe_report, 0, sizeof(sgx_report_t));
  116. //QE_REPORT.BODY.CPUSVN = CPUSVN
  117. if(memcpy_s(&temp_qe_report.body.cpu_svn,
  118. sizeof(temp_qe_report.body.cpu_svn),
  119. cpusvn, sizeof(sgx_cpu_svn_t)))
  120. return SGX_ERROR_UNEXPECTED;
  121. //ProdID same as QE
  122. temp_qe_report.body.isv_prod_id = 1;
  123. //set ISVSVN
  124. temp_qe_report.body.isv_svn = QE_ISVSVN;
  125. //QE_REPORT.BODY.ATTRIBUTES = 0x30000000000000001
  126. temp_qe_report.body.attributes.flags = SGX_FLAGS_INITTED;
  127. temp_qe_report.body.attributes.xfrm = SGX_XFRM_LEGACY;
  128. //QE_REPORT.BODY.MRENCLAVE = 64 0xEE bytes
  129. memset(&temp_qe_report.body.mr_enclave, 0xEE, sizeof(sgx_measurement_t));
  130. //QE_REPORT.BODY.MRSIGNER = random value
  131. if(SGX_SUCCESS != sgx_read_rand((uint8_t *)(&temp_qe_report.body.mr_signer),
  132. sizeof(sgx_measurement_t)))
  133. return SGX_ERROR_UNEXPECTED;
  134. //QE_REPORT.KEYID = <random>
  135. if(SGX_SUCCESS != sgx_read_rand((unsigned char *)&temp_qe_report.key_id,
  136. sizeof(sgx_key_id_t)))
  137. return SGX_ERROR_UNEXPECTED;
  138. //QE_REPORT.BODY.REPORTDATA = SHA256(NONCE || QUOTE)
  139. int sha256_size = 0;
  140. IppsHashState *p_sha_state = NULL;
  141. sgx_status_t sgx_ret = SGX_ERROR_UNEXPECTED;
  142. IppsAES_CMACState* p_cmac_state = NULL;
  143. int ippStateSize = 0;
  144. IppStatus ipp_ret = ippStsNoErr;
  145. //prepare reprot_data
  146. do
  147. {
  148. IppStatus ret;
  149. ret = ippsHashGetSize(&sha256_size);
  150. if(ret)break;
  151. // p_sha_state need to be freed when exit.
  152. p_sha_state = (IppsHashState *)malloc(sha256_size);
  153. if(!p_sha_state)
  154. {
  155. sgx_ret = SGX_ERROR_OUT_OF_MEMORY;
  156. break;
  157. }
  158. ret = ippsHashInit(p_sha_state, IPP_ALG_HASH_SHA256);
  159. if(ret)break;
  160. ret = ippsHashUpdate((uint8_t *)const_cast<sgx_quote_nonce_t*>(p_quote_nonce),
  161. sizeof(sgx_quote_nonce_t),
  162. p_sha_state);
  163. if(ret)break;
  164. ret = ippsHashUpdate(p_quote,
  165. quote_size,
  166. p_sha_state);
  167. if(ret)break;
  168. //sha256 final, QE_REPORT.BODY.REPORTDATA = SHA256(NONCE || QUOTE)
  169. ret = ippsHashFinal((uint8_t*)&temp_qe_report.body.report_data,
  170. p_sha_state);
  171. if(ret)break;
  172. /* calculate CMAC using the report key, same as BASE_REPORT_KEY in
  173. sdk/simulation/tinst/deriv.cpp */
  174. derivation_data_t dd;
  175. memset(&dd, 0, sizeof(dd));
  176. dd.size = sizeof(dd_report_key_t);
  177. dd.key_name = SGX_KEYSELECT_REPORT;
  178. if(memcpy_s(&dd.ddrk.mrenclave,sizeof(dd.ddrk.mrenclave),
  179. &p_report->body.mr_enclave, sizeof(sgx_measurement_t)))
  180. break;
  181. if(memcpy_s(&dd.ddrk.attributes, sizeof(dd.ddrk.attributes),
  182. &p_report->body.attributes, sizeof(sgx_attributes_t)))
  183. break;
  184. if(memcpy_s(&dd.ddrk.csr_owner_epoch, sizeof(dd.ddrk.csr_owner_epoch),
  185. SIMU_OWNER_EPOCH_MSR, sizeof(se_owner_epoch_t)))
  186. break;
  187. if(memcpy_s(&dd.ddrk.cpu_svn, sizeof(dd.ddrk.cpu_svn),
  188. cpusvn, sizeof(sgx_cpu_svn_t)))
  189. break;
  190. if(memcpy_s(&dd.ddrk.key_id, sizeof(dd.ddrk.key_id),
  191. &temp_qe_report.key_id, sizeof(sgx_key_id_t)))
  192. break;
  193. ipp_ret = ippsAES_CMACGetSize(&ippStateSize);
  194. if(ipp_ret != ippStsNoErr)break;
  195. p_cmac_state = (IppsAES_CMACState*)malloc(ippStateSize);
  196. if(p_cmac_state == NULL)
  197. {
  198. sgx_ret = SGX_ERROR_OUT_OF_MEMORY;
  199. break;
  200. }
  201. // calculate the derived key
  202. ipp_ret = ippsAES_CMACInit((const Ipp8u *)BASE_REPORT_KEY, 16,
  203. p_cmac_state, ippStateSize);
  204. if(ipp_ret != ippStsNoErr)
  205. {
  206. if(ipp_ret == ippStsMemAllocErr)
  207. {
  208. sgx_ret = SGX_ERROR_OUT_OF_MEMORY;
  209. break;
  210. }
  211. else
  212. {
  213. sgx_ret = SGX_ERROR_UNEXPECTED;
  214. break;
  215. }
  216. }
  217. ipp_ret = ippsAES_CMACUpdate((const Ipp8u *)dd.ddbuf,
  218. dd.size, p_cmac_state);
  219. if(ipp_ret != ippStsNoErr)break;
  220. sgx_key_128bit_t tmp_report_key;
  221. memset(tmp_report_key, 0, sizeof(tmp_report_key));
  222. ipp_ret = ippsAES_CMACFinal((Ipp8u *)&tmp_report_key,
  223. sizeof(tmp_report_key), p_cmac_state);
  224. if(ipp_ret != ippStsNoErr)break;
  225. // call cryptographic CMAC function
  226. // CMAC data are *NOT* including MAC and KEYID
  227. ipp_ret = ippsAES_CMACInit((const Ipp8u *)tmp_report_key, 16,
  228. p_cmac_state, ippStateSize);
  229. if(ipp_ret != ippStsNoErr)
  230. {
  231. if(ipp_ret == ippStsMemAllocErr)
  232. {
  233. sgx_ret = SGX_ERROR_OUT_OF_MEMORY;
  234. break;
  235. }
  236. else
  237. {
  238. sgx_ret = SGX_ERROR_UNEXPECTED;
  239. break;
  240. }
  241. }
  242. ipp_ret = ippsAES_CMACUpdate((const Ipp8u *)&temp_qe_report.body,
  243. sizeof(temp_qe_report.body),
  244. p_cmac_state);
  245. if(ipp_ret != ippStsNoErr)break;
  246. ipp_ret = ippsAES_CMACFinal((Ipp8u *)&temp_qe_report.mac,
  247. sizeof(temp_qe_report.mac), p_cmac_state);
  248. if(ipp_ret != ippStsNoErr)break;
  249. if(memcpy_s(p_qe_report, sizeof(*p_qe_report),
  250. &temp_qe_report, sizeof(temp_qe_report)))
  251. break;
  252. sgx_ret = SGX_SUCCESS;
  253. }while(0);
  254. if (p_cmac_state)
  255. free(p_cmac_state);
  256. if(p_sha_state)
  257. free(p_sha_state);
  258. return sgx_ret;
  259. }
  260. /*
  261. * For quote with SIG-RL
  262. * |--------------------------------------------------------------------|
  263. * |sgx_quote_t|wrap_key_t|iv|payload_size|basic_sig|rl_ver|n2|nrp..|mac|
  264. * |--------------------------------------------------------------------|
  265. * For quote without SIG-RL
  266. * |--------------------------------------------------------------|
  267. * |sgx_quote_t|wrap_key_t|iv|payload_size|basic_sig|rl_ver|n2|mac|
  268. * |--------------------------------------------------------------|
  269. */
  270. sgx_status_t sgx_get_quote(
  271. const sgx_report_t *p_report,
  272. sgx_quote_sign_type_t quote_type,
  273. const sgx_spid_t *p_spid,
  274. const sgx_quote_nonce_t *p_nonce,
  275. const uint8_t *p_sig_rl,
  276. uint32_t sig_rl_size,
  277. sgx_report_t *p_qe_report,
  278. sgx_quote_t *p_quote,
  279. uint32_t quote_size)
  280. {
  281. sgx_status_t ret = SGX_SUCCESS;
  282. GroupPubKey *p_epid_group_cert = (GroupPubKey *)const_cast<uint8_t*>(EPID_GROUP_CERT);
  283. unsigned int rl_entry_count = 0;
  284. sgx_basename_t basename = {{0}};
  285. uint64_t required_buffer_size = 0;
  286. se_encrypted_sign_t *p_signature = NULL;
  287. sgx_cpu_svn_t cpusvn = {{0}};
  288. uint8_t *p_mac = NULL;
  289. if(!p_report || !p_spid || !p_quote || !quote_size)
  290. return SGX_ERROR_INVALID_PARAMETER;
  291. if(!p_nonce && p_qe_report)
  292. return SGX_ERROR_INVALID_PARAMETER;
  293. if(p_nonce && !p_qe_report)
  294. return SGX_ERROR_INVALID_PARAMETER;
  295. if(p_sig_rl && sig_rl_size < sizeof(se_sig_rl_t))
  296. return SGX_ERROR_INVALID_PARAMETER;
  297. if(!p_sig_rl && sig_rl_size)
  298. return SGX_ERROR_INVALID_PARAMETER;
  299. if(quote_type != SGX_UNLINKABLE_SIGNATURE
  300. && quote_type != SGX_LINKABLE_SIGNATURE)
  301. return SGX_ERROR_INVALID_PARAMETER;
  302. if(p_sig_rl){
  303. //Check the size of SIG-RL.
  304. se_sig_rl_t *p_sig_rl_temp = (se_sig_rl_t *)const_cast<uint8_t*>(p_sig_rl);
  305. uint64_t required_sig_rl_size = se_get_sig_rl_size(p_sig_rl_temp);
  306. rl_entry_count = ntohl(p_sig_rl_temp->sig_rl.n2);
  307. if(required_sig_rl_size > sig_rl_size)
  308. {
  309. ret = SGX_ERROR_INVALID_PARAMETER;
  310. goto CLEANUP;
  311. }
  312. }
  313. se_static_assert(sizeof(basename) > sizeof(sgx_spid_t));
  314. /* Because basename has already been zerod,
  315. so we don't need to concatenating with 0s.*/
  316. if(memcpy_s(&basename, sizeof(basename), p_spid, sizeof(sgx_spid_t)))
  317. {
  318. ret = SGX_ERROR_UNEXPECTED;
  319. goto CLEANUP;
  320. }
  321. if(SGX_UNLINKABLE_SIGNATURE == quote_type)
  322. {
  323. uint8_t *p = (uint8_t *)&basename + sizeof(sgx_spid_t);
  324. if(SGX_SUCCESS != sgx_read_rand(p,
  325. sizeof(basename) - sizeof(sgx_spid_t)))
  326. {
  327. ret = SGX_ERROR_UNEXPECTED;
  328. goto CLEANUP;
  329. }
  330. }
  331. /* sign_size returned from epidMember_signMessage including the RLver
  332. and n2. */
  333. required_buffer_size = sizeof(sgx_quote_t)
  334. + sizeof(se_wrap_key_t)
  335. + 12 // size of payload_iv
  336. + 4 // size of payload_size
  337. + sizeof(BasicSignature)
  338. + sizeof(RLver_t)
  339. + sizeof(RLCount)
  340. + 16; // size of payload_mac
  341. if(p_sig_rl){
  342. required_buffer_size += (sizeof(NrProof) * rl_entry_count);
  343. }
  344. /* If the p_quote is not NULL, then we should make sure the buffer size is
  345. * correct. */
  346. if(quote_size < required_buffer_size){
  347. ret = SGX_ERROR_INVALID_PARAMETER;
  348. goto CLEANUP;
  349. }
  350. if(SGX_SUCCESS != get_cpusvn(&cpusvn))
  351. {
  352. ret = SGX_ERROR_UNEXPECTED;
  353. goto CLEANUP;
  354. }
  355. if(memcmp(&cpusvn, &((const sgx_report_t *)p_report)->body.cpu_svn,
  356. sizeof(sgx_cpu_svn_t)))
  357. {
  358. ret = SGX_ERROR_INVALID_PARAMETER;
  359. goto CLEANUP;
  360. }
  361. /* Copy the data in the report into quote body. */
  362. memset(p_quote, 0xEE, quote_size);
  363. p_quote->version = 1;
  364. p_quote->sign_type = (uint16_t)quote_type;
  365. p_quote->epid_group_id[0] = p_epid_group_cert->gid.data[3];
  366. p_quote->epid_group_id[1] = p_epid_group_cert->gid.data[2];
  367. p_quote->epid_group_id[2] = p_epid_group_cert->gid.data[1];
  368. p_quote->epid_group_id[3] = p_epid_group_cert->gid.data[0];
  369. p_quote->qe_svn = QE_ISVSVN;
  370. if(memcpy_s(&p_quote->basename, sizeof(sgx_basename_t),
  371. &basename, sizeof(basename))){
  372. ret = SGX_ERROR_UNEXPECTED;
  373. goto CLEANUP;
  374. }
  375. if(memcpy_s(&p_quote->report_body, sizeof(p_quote->report_body),
  376. &((const sgx_report_t *)p_report)->body, sizeof(sgx_report_body_t)))
  377. {
  378. ret = SGX_ERROR_UNEXPECTED;
  379. goto CLEANUP;
  380. }
  381. p_quote->signature_len = (uint32_t)(required_buffer_size - sizeof(sgx_quote_t));
  382. // Set the payload_size
  383. p_signature = (se_encrypted_sign_t *)(p_quote->signature);
  384. p_signature->payload_size = (uint32_t)(sizeof(BasicSignature)
  385. + sizeof(RLver_t)
  386. + sizeof(RLCount)
  387. + (sizeof(NrProof) * rl_entry_count));
  388. if(SGX_SUCCESS != sgx_read_rand(p_signature->iv, sizeof(p_signature->iv)))
  389. {
  390. ret = SGX_ERROR_UNEXPECTED;
  391. goto CLEANUP;
  392. }
  393. p_mac = (uint8_t *)(&p_signature->basic_sign) + p_signature->payload_size;
  394. if(SGX_SUCCESS != sgx_read_rand(p_mac, 16))
  395. {
  396. ret = SGX_ERROR_UNEXPECTED;
  397. goto CLEANUP;
  398. }
  399. if(p_qe_report)
  400. ret = create_qe_report(p_report, p_nonce, (uint8_t*)p_quote,
  401. quote_size, &cpusvn, p_qe_report);
  402. CLEANUP:
  403. return ret;
  404. } //sgx_get_quote
  405. sgx_status_t SGXAPI sgx_report_attestation_status(
  406. const sgx_platform_info_t *p_platform_info,
  407. int attestation_status,
  408. sgx_update_info_bit_t *p_update_info)
  409. {
  410. UNUSED(p_platform_info);
  411. UNUSED(attestation_status);
  412. memset(p_update_info, 0, sizeof(sgx_update_info_bit_t));
  413. return SGX_SUCCESS;
  414. }
  415. sgx_status_t SGXAPI sgx_get_extended_epid_group_id(uint32_t* p_extended_epid_group_id)
  416. {
  417. *p_extended_epid_group_id = 0;
  418. return SGX_SUCCESS;
  419. }
  420. sgx_status_t SGXAPI sgx_get_whitelist_size(uint32_t* p_whitelist_size)
  421. {
  422. *p_whitelist_size = 0;
  423. return SGX_SUCCESS;
  424. }
  425. sgx_status_t SGXAPI sgx_get_whitelist(uint8_t* p_whitelist, uint32_t whitelist_size)
  426. {
  427. UNUSED(p_whitelist);
  428. if(whitelist_size!=0){
  429. return SGX_ERROR_INVALID_PARAMETER;
  430. }else{
  431. return SGX_SUCCESS;
  432. }
  433. }