• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
23 #include <epid/member/api.h>
24 
25 #include <stddef.h>
26 #include "epid/common/bitsupplier.h"
27 #include "epid/common/errors.h"
28 #include "epid/common/stdtypes.h"
29 #include "epid/common/types.h"
30 
31 /// \cond
32 typedef struct Tpm2Ctx Tpm2Ctx;
33 typedef struct Epid2Params_ Epid2Params_;
34 typedef struct AllowedBasenames AllowedBasenames;
35 typedef struct Stack Stack;
36 typedef struct EcPoint EcPoint;
37 typedef struct FfElement FfElement;
38 /// \endcond
39 
40 /// Member context definition
41 struct MemberCtx {
42   Epid2Params_* epid2_params;  ///< Intel(R) EPID 2.0 params
43   Tpm2Ctx* tpm2_ctx;           ///< TPM2 context
44   GroupPubKey pub_key;         ///< group public key
45   MemberPrecomp precomp;       ///< Member pre-computed data
46   BitSupplier rnd_func;        ///< Pseudo random number generation function
47   void* rnd_param;             ///< Pointer to user context for rnd_func
48   SigRl const* sig_rl;         ///< Signature based revocation list - not owned
49   AllowedBasenames* allowed_basenames;  ///< Base name list
50   HashAlg hash_alg;                     ///< Hash algorithm to use
51   MembershipCredential credential;      ///< Membership credential
52   bool primary_key_set;                 ///< primary key is set
53   bool precomp_ready;  ///< provisioned precomputed value is ready for use
54   bool is_initially_provisioned;  ///< f initialized
55   bool is_provisioned;   ///< member fully provisioned with key material
56   EcPoint const* h1;     ///< Group public key h1 value
57   EcPoint const* h2;     ///< Group group public key h2 value
58   EcPoint const* A;      ///< Membership Credential A value
59   FfElement const* x;    ///< Membership Credential x value
60   EcPoint const* w;      ///< Group group public key w value
61   FfElement const* e12;  ///< an element in GT, = pairing (h1, g2)
62   FfElement const* e22;  ///< an element in GT, = pairing (h2, g2)
63   FfElement const* e2w;  ///< an element in GT, = pairing (h2, w)
64   FfElement const* ea2;  ///< an element in GT, = pairing (g1, g2)
65   uint16_t join_ctr;     ///< counter for join commands
66   uint16_t rf_ctr;       ///< a TPM commit counter for rf
67   uint16_t rnu_ctr;  ///< TPM counter pointing to Nr Proof related random value
68   FpElemStr const* f;  ///< If NULL an EPS based f is used otherwise f is
69                        ///  stored in TPM using load external
70   Stack* presigs;      ///< Pre-computed signature pool
71 };
72 
73 /// Pre-computed signature.
74 /*!
75  Serialized form of an intermediate signature that does not depend on
76  basename or message. This can be used to time-shift compute time needed to
77  sign a message.
78  */
79 #pragma pack(1)
80 typedef struct PreComputedSignature {
81   G1ElemStr B;        ///< an element in G1
82   G1ElemStr K;        ///< an element in G1
83   G1ElemStr T;        ///< an element in G1
84   G1ElemStr R1;       ///< an element in G1
85   GtElemStr R2;       ///< an element in G1
86   FpElemStr a;        ///< an integer between [0, p-1]
87   FpElemStr b;        ///< an integer between [0, p-1]
88   FpElemStr rx;       ///< an integer between [0, p-1]
89   uint16_t rf_ctr;    ///< a TPM commit counter for rf
90   FpElemStr ra;       ///< an integer between [0, p-1]
91   FpElemStr rb;       ///< an integer between [0, p-1]
92   BigNumStr rnd_bsn;  ///< random basename
93 } PreComputedSignature;
94 #pragma pack()
95 
96 /// Minimally provision member with f
97 EpidStatus EpidMemberInitialProvision(MemberCtx* ctx);
98 
99 #endif  // EPID_MEMBER_SRC_CONTEXT_H_
100