context.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*############################################################################
  2. # Copyright 2016-2017 Intel Corporation
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################*/
  16. #ifndef EPID_MEMBER_SRC_CONTEXT_H_
  17. #define EPID_MEMBER_SRC_CONTEXT_H_
  18. /*!
  19. * \file
  20. * \brief Member context interface.
  21. */
  22. #include <epid/member/api.h>
  23. #include <stddef.h>
  24. #include "epid/common/bitsupplier.h"
  25. #include "epid/common/errors.h"
  26. #include "epid/common/stdtypes.h"
  27. #include "epid/common/types.h"
  28. /// \cond
  29. typedef struct Tpm2Ctx Tpm2Ctx;
  30. typedef struct Epid2Params_ Epid2Params_;
  31. typedef struct AllowedBasenames AllowedBasenames;
  32. typedef struct Stack Stack;
  33. typedef struct EcPoint EcPoint;
  34. typedef struct FfElement FfElement;
  35. /// \endcond
  36. /// Member context definition
  37. struct MemberCtx {
  38. Epid2Params_* epid2_params; ///< Intel(R) EPID 2.0 params
  39. Tpm2Ctx* tpm2_ctx; ///< TPM2 context
  40. GroupPubKey pub_key; ///< group public key
  41. MemberPrecomp precomp; ///< Member pre-computed data
  42. BitSupplier rnd_func; ///< Pseudo random number generation function
  43. void* rnd_param; ///< Pointer to user context for rnd_func
  44. SigRl const* sig_rl; ///< Signature based revocation list - not owned
  45. AllowedBasenames* allowed_basenames; ///< Base name list
  46. HashAlg hash_alg; ///< Hash algorithm to use
  47. MembershipCredential credential; ///< Membership credential
  48. bool primary_key_set; ///< primary key is set
  49. bool precomp_ready; ///< provisioned precomputed value is ready for use
  50. bool is_initially_provisioned; ///< f initialized
  51. bool is_provisioned; ///< member fully provisioned with key material
  52. EcPoint const* h1; ///< Group public key h1 value
  53. EcPoint const* h2; ///< Group group public key h2 value
  54. EcPoint const* A; ///< Membership Credential A value
  55. FfElement const* x; ///< Membership Credential x value
  56. EcPoint const* w; ///< Group group public key w value
  57. FfElement const* e12; ///< an element in GT, = pairing (h1, g2)
  58. FfElement const* e22; ///< an element in GT, = pairing (h2, g2)
  59. FfElement const* e2w; ///< an element in GT, = pairing (h2, w)
  60. FfElement const* ea2; ///< an element in GT, = pairing (g1, g2)
  61. uint16_t join_ctr; ///< counter for join commands
  62. uint16_t rf_ctr; ///< a TPM commit counter for rf
  63. uint16_t rnu_ctr; ///< TPM counter pointing to Nr Proof related random value
  64. FpElemStr const* f; ///< If NULL an EPS based f is used otherwise f is
  65. /// stored in TPM using load external
  66. Stack* presigs; ///< Pre-computed signature pool
  67. };
  68. /// Pre-computed signature.
  69. /*!
  70. Serialized form of an intermediate signature that does not depend on
  71. basename or message. This can be used to time-shift compute time needed to
  72. sign a message.
  73. */
  74. #pragma pack(1)
  75. typedef struct PreComputedSignature {
  76. G1ElemStr B; ///< an element in G1
  77. G1ElemStr K; ///< an element in G1
  78. G1ElemStr T; ///< an element in G1
  79. G1ElemStr R1; ///< an element in G1
  80. GtElemStr R2; ///< an element in G1
  81. FpElemStr a; ///< an integer between [0, p-1]
  82. FpElemStr b; ///< an integer between [0, p-1]
  83. FpElemStr rx; ///< an integer between [0, p-1]
  84. uint16_t rf_ctr; ///< a TPM commit counter for rf
  85. FpElemStr ra; ///< an integer between [0, p-1]
  86. FpElemStr rb; ///< an integer between [0, p-1]
  87. BigNumStr rnd_bsn; ///< random basename
  88. } PreComputedSignature;
  89. #pragma pack()
  90. /// Minimally provision member with f
  91. EpidStatus EpidMemberInitialProvision(MemberCtx* ctx);
  92. #endif // EPID_MEMBER_SRC_CONTEXT_H_