context.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*############################################################################
  2. # Copyright 2016 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 <stddef.h>
  23. #include "epid/member/api.h"
  24. #include "epid/common/errors.h"
  25. #include "epid/common/src/epid2params.h"
  26. #include "epid/common/src/grouppubkey.h"
  27. #include "epid/common/src/stack.h"
  28. #include "epid/common/src/commitment.h"
  29. #include "epid/member/src/privkey.h"
  30. /// Internal implementation of base name
  31. typedef struct AllowedBasename {
  32. struct AllowedBasename* next; ///< pointer to the next base name
  33. size_t length; ///< size of base name
  34. uint8_t name[1]; ///< base name (flexible array)
  35. } AllowedBasename;
  36. /// Member context definition
  37. struct MemberCtx {
  38. GroupPubKey_* pub_key; ///< group public key
  39. FfElement* e12; ///< an element in GT
  40. FfElement* e22; ///< an element in GT
  41. FfElement* e2w; ///< an element in GT
  42. FfElement* ea2; ///< an element in GT
  43. Epid2Params_* epid2_params; ///< Intel(R) EPID 2.0 params
  44. PrivKey_* priv_key; ///< Member private key
  45. BitSupplier rnd_func; ///< Pseudo random number generation function
  46. void* rnd_param; ///< Pointer to user context for rnd_func
  47. HashAlg hash_alg; ///< Hash algorithm to use
  48. AllowedBasename* allowed_basenames; ///< Base name list
  49. Stack* presigs; ///< Pre-computed signatures pool
  50. CommitValues commit_values; ///< Values that are hashed to create commitment
  51. };
  52. /// Delete base name list
  53. void DeleteBasenames(AllowedBasename** rootnode);
  54. /// Add new base name to list
  55. EpidStatus AddBasename(AllowedBasename** rootnode, void const* basename,
  56. size_t length);
  57. /// Check if given base name exist in the list
  58. bool ContainsBasename(AllowedBasename const* rootnode, void const* basename,
  59. size_t length);
  60. /// Performs Pre-computation that can be used to speed up signing
  61. /*!
  62. \warning
  63. Do not re-use the same pre-computed signature to generate more than
  64. one signature. If a pre-computed signature is used for computing
  65. two signatures, an attacker could learn the Intel(R) EPID private key.
  66. \param[in] ctx
  67. The member context.
  68. \param[out] precompsig
  69. The pre-computed signature.
  70. \returns ::EpidStatus
  71. */
  72. EpidStatus EpidComputePreSig(MemberCtx const* ctx,
  73. PreComputedSignature* precompsig);
  74. #endif // EPID_MEMBER_SRC_CONTEXT_H_