pse_pr_sigma_1_1_defs.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright (C) 2011-2018 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. /**
  32. @file Sigma_1_1_defs.h
  33. @author Kapil Anantharaman
  34. @brief This file contains the data structures for sigma 1.1 protocol
  35. */
  36. #ifndef PSE_PR_SIGMA_1_1_DEFS_H
  37. #define PSE_PR_SIGMA_1_1_DEFS_H
  38. #include "pse_pr_sigma_common_defs.h"
  39. #define SIGMA_MAX_SIG_RL_ENTRY 100
  40. #define MAX_WORK_BUFFER_SIZE 400
  41. #define MAX_VERIFIER_CERT_SIZE 600
  42. #ifndef C_ASSERT
  43. #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
  44. //#define C_ASSERT(e) /* nothing */
  45. #endif
  46. #pragma pack(1)
  47. typedef UINT32 EPID_GID;
  48. typedef UINT8 EphemeralPublicKey[SIGMA_SESSION_PUBKEY_LENGTH];
  49. typedef UINT8 SIGMA_HMAC[SIGMA_HMAC_LENGTH];
  50. typedef UINT8 VERIFIER_SIGNATURE[ECDSA_SIG_LENGTH];
  51. typedef UINT8 SIGMA_BASENAME[SIGMA_BASENAME_LENGTH];
  52. /*! \brief The beginning of the Signature based Revocation List.
  53. *
  54. * SIG_RL header is present even if the revocation list is empty.
  55. *
  56. */
  57. typedef struct _SIG_RL_HEADER
  58. {
  59. UINT8 Sver[2];
  60. // SafeId BlobId
  61. UINT8 Blobid[2];
  62. EPID_GID Gid;
  63. UINT32 RLver;
  64. UINT32 n2;
  65. }SIG_RL_HEADER;
  66. C_ASSERT(sizeof(SIG_RL_HEADER) == 16);
  67. #pragma pack()
  68. //calculate size of SIG-RL based on n2 - number of entries)
  69. #define GET_SIG_RL_SIZE(SIG_RL_ENTRIES) \
  70. (sizeof(SIG_RL_HEADER) + (1024 * SIG_RL_ENTRIES + 512)/8)
  71. typedef enum _TASK_INFO_TYPE {
  72. ME_TASK = 0,
  73. SE_TASK,
  74. MAX_TASK,
  75. }TASK_INFO_TYPE;
  76. typedef struct _SIGMA_TASK_INFO_HDR {
  77. TASK_INFO_TYPE Type;
  78. unsigned int TaskInfoLen;
  79. }SIGMA_TASK_INFO_HDR;
  80. typedef struct _ME_TASK_INFO {
  81. SIGMA_TASK_INFO_HDR Hdr;
  82. unsigned int TaskId;
  83. unsigned int SubTaskId;
  84. unsigned char RsvdMECore[32];
  85. unsigned char RsvdforApp[32];
  86. } ME_TASK_INFO;
  87. #define DAL_APPLET_ID_LEN 16
  88. #define DAL_APPLET_SVN_LEN 4
  89. #define JOM_TASK_ID 8
  90. /*
  91. OCSP Request and Response
  92. */
  93. typedef enum _OCSP_REQ_TYPE {
  94. NO_OCSP = 0,
  95. CACHED = 1,
  96. NON_CACHED = 2,
  97. MAX_OCSP_TYPE= 3,
  98. } OCSP_REQ_TYPE;
  99. #pragma pack(1)
  100. typedef struct _OCSP_REQ {
  101. OCSP_REQ_TYPE ReqType;
  102. SIGMA_NONCE OcspNonce;
  103. } OCSP_REQ;
  104. /**
  105. \defgroup SigmaMessages SIGMA MESSAGES
  106. */
  107. /**
  108. \ingroup SigmaMessages
  109. \brief S1 message sent from ME FW to verifier
  110. */
  111. typedef struct _SIGMA_S1_MESSAGE
  112. {
  113. EphemeralPublicKey Ga;
  114. EPID_GID Gid;
  115. OCSP_REQ OcspReq;
  116. }SIGMA_S1_MESSAGE;
  117. /**
  118. \ingroup SigmaMessages
  119. \brief S2 message sent from verifier to ME FW.
  120. */
  121. typedef struct _SIGMA_S2_MESSAGE
  122. {
  123. VERIFIER_SIGNATURE SigGaGb;
  124. SIGMA_HMAC S2Icv;
  125. EphemeralPublicKey Gb;
  126. SIGMA_BASENAME Basename;
  127. OCSP_REQ OcspReq;
  128. UINT8 Data[0];
  129. }SIGMA_S2_MESSAGE;
  130. /**
  131. \ingroup SigmaMessages
  132. \brief S3 message sent from ME FW to verifier
  133. */
  134. typedef struct _SIGMA_S3_MESSAGE
  135. {
  136. SIGMA_HMAC S3Icv;
  137. ME_TASK_INFO TaskInfo;
  138. EphemeralPublicKey Ga;
  139. UINT8 Data[0];
  140. }SIGMA_S3_MESSAGE;
  141. #pragma pack()
  142. // This is the constant size portion of the S2 message that is part of the ICV
  143. #define SIGMA_S2_ICV_CONSTANT_BUFFER_SIZE (sizeof(EphemeralPublicKey) + sizeof(SIGMA_BASENAME) + sizeof(OCSP_REQ))
  144. #endif