service_provider.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 _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_INTEGRITY_FAILED,
  42. SP_QUOTE_VERIFICATION_FAILED,
  43. SP_IAS_FAILED,
  44. SP_INTERNAL_ERROR,
  45. SP_PROTOCOL_ERROR,
  46. } sp_ra_msg_status_t;
  47. #pragma pack(push,1)
  48. #define SAMPLE_SP_TAG_SIZE 16
  49. #define SAMPLE_SP_IV_SIZE 12
  50. typedef struct sample_ec_pub_t
  51. {
  52. uint8_t gx[SAMPLE_ECP_KEY_SIZE];
  53. uint8_t gy[SAMPLE_ECP_KEY_SIZE];
  54. } sample_ec_pub_t;
  55. //fixed length to align with internal structure
  56. typedef struct sample_ps_sec_prop_desc_t
  57. {
  58. uint8_t sample_ps_sec_prop_desc[256];
  59. } sample_ps_sec_prop_desc_t;
  60. #pragma pack(pop)
  61. typedef uint32_t sample_ra_context_t;
  62. typedef uint8_t sample_key_128bit_t[16];
  63. typedef sample_key_128bit_t sample_ra_key_128_t;
  64. typedef struct sample_ra_msg1_t
  65. {
  66. sample_ec_pub_t g_a; // the Endian-ness of Ga is
  67. // Little-Endian
  68. sample_epid_group_id_t gid; // the Endian-ness of GID is
  69. // Little-Endian
  70. } sample_ra_msg1_t;
  71. //Key Derivation Function ID : 0x0001 AES-CMAC Entropy Extraction and Key Expansion
  72. const uint16_t SAMPLE_AES_CMAC_KDF_ID = 0x0001;
  73. typedef struct sample_ra_msg2_t
  74. {
  75. sample_ec_pub_t g_b; // the Endian-ness of Gb is
  76. // Little-Endian
  77. sample_spid_t spid;
  78. uint16_t quote_type; /* unlinkable Quote(0) or linkable Quote(0) in little endian*/
  79. uint16_t kdf_id; /* key derivation function id in little endian.
  80. 0x0001 for AES-CMAC Entropy Extraction and Key Derivation */
  81. sample_ec_sign256_t sign_gb_ga; // In little endian
  82. sample_mac_t mac; // mac_smk(g_b||spid||quote_type||
  83. // sign_gb_ga)
  84. uint32_t sig_rl_size;
  85. uint8_t sig_rl[];
  86. } sample_ra_msg2_t;
  87. typedef struct sample_ra_msg3_t
  88. {
  89. sample_mac_t mac; // mac_smk(g_a||ps_sec_prop||quote)
  90. sample_ec_pub_t g_a; // the Endian-ness of Ga is
  91. // Little-Endian
  92. sample_ps_sec_prop_desc_t ps_sec_prop;
  93. uint8_t quote[];
  94. } sample_ra_msg3_t;
  95. int sp_ra_proc_msg1_req(const sample_ra_msg1_t *p_msg1,
  96. uint32_t msg1_size,
  97. ra_samp_response_header_t **pp_msg2);
  98. int sp_ra_proc_msg3_req(const sample_ra_msg3_t *p_msg3,
  99. uint32_t msg3_size,
  100. ra_samp_response_header_t **pp_att_result_msg);
  101. int sp_ra_free_msg2(
  102. sample_ra_msg2_t *p_msg2);
  103. #ifdef __cplusplus
  104. }
  105. #endif
  106. #endif