pse_pr_types.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. #ifndef _TYPES_H_
  32. #define _TYPES_H_
  33. #include <stdint.h>
  34. #ifndef UINT64
  35. #define UINT64 uint64_t
  36. #endif
  37. #ifndef UINT32
  38. #define UINT32 uint32_t
  39. #endif
  40. #ifndef UINT16
  41. #define UINT16 uint16_t
  42. #endif
  43. #ifndef UINT8
  44. #define UINT8 uint8_t
  45. #endif
  46. #ifndef BYTE
  47. #define BYTE uint8_t
  48. #endif
  49. #define SIGMA_HMAC_LENGTH 32
  50. #define ECDSA_PRIVKEY_LEN 32
  51. #define ECDSA_PUBKEY_LEN 64
  52. #define ECDSA_SIGNATURE_LEN 64
  53. #define SIGMA_PRIVKEY_LEN 32
  54. #define SIGMA_PUBKEY_LEN 64
  55. #define EPID_PUBKEY_LEN 328
  56. #define PRIV_RL_ENTRY 32
  57. typedef uint32_t SHA256_HASH[8];
  58. typedef uint8_t SIGMA_HMAC[SIGMA_HMAC_LENGTH];
  59. typedef uint8_t Nonce128_t[16];
  60. typedef UINT8 PR_PSE_T[32];
  61. typedef UINT32 STATUS;
  62. #define SAFEID_CRYPTO_CONTEXT_LEN sizeof(SAFEID_CRYPTO_CONTEXT)
  63. typedef uint8_t EcDsaPrivKey[ECDSA_PRIVKEY_LEN];
  64. typedef uint8_t EcDsaPubKey[ECDSA_PUBKEY_LEN];
  65. typedef uint8_t EcDsaSig[ECDSA_SIGNATURE_LEN];
  66. typedef uint32_t SAFEID_GID;
  67. #pragma pack(push, 1)
  68. typedef struct
  69. {
  70. UINT8 first[ECDSA_PUBKEY_LEN];
  71. UINT8 second[ECDSA_PUBKEY_LEN];
  72. } KeysToSign_t;
  73. /*
  74. ** 3.1.1.2.1 EPID Certificate
  75. */
  76. typedef struct _EpidCert
  77. {
  78. unsigned char PubKeyEpid[EPID_PUBKEY_LEN];
  79. EcDsaSig SignIntel;
  80. } EpidCert;
  81. typedef struct _SAFEID_CRYPTO_CONTEXT
  82. {
  83. /// SafeId serialization tags
  84. // SafeId version
  85. UINT8 Sver[2];
  86. // SafeId BlobId
  87. UINT8 Blobid[2];
  88. UINT8 p[32];
  89. UINT8 q[32];
  90. UINT8 h[4];
  91. UINT8 a[32];
  92. UINT8 b[32];
  93. UINT8 coeff0[32];
  94. UINT8 coeff1[32];
  95. UINT8 coeff2[32];
  96. UINT8 qnr[32];
  97. UINT8 orderG2[96];
  98. UINT8 pp[32];
  99. UINT8 qp[32];
  100. UINT8 hp[4];
  101. UINT8 ap[32];
  102. UINT8 bp[32];
  103. UINT8 g1[64];
  104. UINT8 g2[192];
  105. UINT8 g3[64];
  106. // Intel root signature
  107. UINT8 eccDsaSignature[ECDSA_SIGNATURE_LEN];
  108. } SAFEID_CRYPTO_CONTEXT;
  109. #pragma pack(pop)
  110. #endif