service_provider.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 _SERVICE_PROVIDER_H
  32. #define _SERVICE_PROVIDER_H
  33. #include "remote_attestation_result.h"
  34. #include "ias_ra.h"
  35. #include "network_ra.h"
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. typedef enum {
  40. SP_OK,
  41. SP_UNSUPPORTED_EXTENDED_EPID_GROUP,
  42. SP_INTEGRITY_FAILED,
  43. SP_QUOTE_VERIFICATION_FAILED,
  44. SP_IAS_FAILED,
  45. SP_INTERNAL_ERROR,
  46. SP_PROTOCOL_ERROR,
  47. SP_QUOTE_VERSION_ERROR,
  48. } sp_ra_msg_status_t;
  49. #pragma pack(push,1)
  50. #define SAMPLE_SP_TAG_SIZE 16
  51. #define SAMPLE_SP_IV_SIZE 12
  52. typedef struct sample_ec_pub_t
  53. {
  54. uint8_t gx[SAMPLE_ECP_KEY_SIZE];
  55. uint8_t gy[SAMPLE_ECP_KEY_SIZE];
  56. } sample_ec_pub_t;
  57. /*fixed length to align with internal structure*/
  58. typedef struct sample_ps_sec_prop_desc_t
  59. {
  60. uint8_t sample_ps_sec_prop_desc[256];
  61. } sample_ps_sec_prop_desc_t;
  62. #pragma pack(pop)
  63. typedef uint32_t sample_ra_context_t;
  64. typedef uint8_t sample_key_128bit_t[16];
  65. typedef sample_key_128bit_t sample_ra_key_128_t;
  66. typedef struct sample_ra_msg0_t
  67. {
  68. uint32_t extended_epid_group_id;
  69. } sample_ra_msg0_t;
  70. typedef struct sample_ra_msg1_t
  71. {
  72. sample_ec_pub_t g_a; /* the Endian-ness of Ga is
  73. Little-Endian*/
  74. sample_epid_group_id_t gid; /* the Endian-ness of GID is
  75. Little-Endian*/
  76. } sample_ra_msg1_t;
  77. /*Key Derivation Function ID : 0x0001 AES-CMAC Entropy Extraction and Key Expansion*/
  78. const uint16_t SAMPLE_AES_CMAC_KDF_ID = 0x0001;
  79. typedef struct sample_ra_msg2_t
  80. {
  81. sample_ec_pub_t g_b; /* the Endian-ness of Gb is
  82. Little-Endian*/
  83. sample_spid_t spid; /* In little endian*/
  84. uint16_t quote_type; /* unlinkable Quote(0) or linkable Quote(0) in little endian*/
  85. uint16_t kdf_id; /* key derivation function id in little endian.
  86. 0x0001 for AES-CMAC Entropy Extraction and Key Derivation */
  87. sample_ec_sign256_t sign_gb_ga; /* In little endian*/
  88. sample_mac_t mac; /* mac_smk(g_b||spid||quote_type||
  89. sign_gb_ga)*/
  90. uint32_t sig_rl_size;
  91. uint8_t sig_rl[];
  92. } sample_ra_msg2_t;
  93. typedef struct sample_ra_msg3_t
  94. {
  95. sample_mac_t mac; /* mac_smk(g_a||ps_sec_prop||quote)*/
  96. sample_ec_pub_t g_a; /* the Endian-ness of Ga is*/
  97. /* Little-Endian*/
  98. sample_ps_sec_prop_desc_t ps_sec_prop;
  99. uint8_t quote[];
  100. } sample_ra_msg3_t;
  101. int sp_ra_proc_msg0_req(const sample_ra_msg0_t *p_msg0,
  102. uint32_t msg0_size);
  103. int sp_ra_proc_msg1_req(const sample_ra_msg1_t *p_msg1,
  104. uint32_t msg1_size,
  105. ra_samp_response_header_t **pp_msg2);
  106. int sp_ra_proc_msg3_req(const sample_ra_msg3_t *p_msg3,
  107. uint32_t msg3_size,
  108. ra_samp_response_header_t **pp_att_result_msg);
  109. int sp_ra_free_msg2(
  110. sample_ra_msg2_t *p_msg2);
  111. typedef int (*sample_enroll)(int sp_credentials, sample_spid_t* spid,
  112. int* authentication_token);
  113. typedef int(*sample_get_sigrl)(const sample_epid_group_id_t gid, uint32_t* p_sig_rl_size,
  114. uint8_t** p_sig_rl);
  115. typedef int(*sample_verify_attestation_evidence)(sample_quote_t* p_isv_quote,
  116. uint8_t* pse_manifest,
  117. ias_att_report_t* attestation_verification_report);
  118. typedef struct sample_extended_epid_group
  119. {
  120. uint32_t extended_epid_group_id;
  121. sample_enroll enroll;
  122. sample_get_sigrl get_sigrl;
  123. sample_verify_attestation_evidence verify_attestation_evidence;
  124. } sample_extended_epid_group;
  125. #ifdef __cplusplus
  126. }
  127. #endif
  128. #endif