1 /*############################################################################ 2 # Copyright 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 /// Member context interface. 17 /*! \file */ 18 #ifndef EPID_MEMBER_TINY_SRC_CONTEXT_H_ 19 #define EPID_MEMBER_TINY_SRC_CONTEXT_H_ 20 #include "epid/common/bitsupplier.h" 21 #include "epid/common/types.h" 22 #include "epid/member/tiny/math/mathtypes.h" 23 #include "epid/member/tiny/src/allowed_basenames.h" 24 #include "epid/member/tiny/src/native_types.h" 25 26 /// Size of SigRl with zero entries 27 #define MIN_SIGRL_SIZE (sizeof(SigRl) - sizeof(SigRlEntry)) 28 29 #ifdef USE_SIGRL_BY_REFERENCE 30 31 // SIZE_MAX is not guaranteed in C89/90 32 #define SIZE_T_MAX ((size_t)(-1)) 33 34 /// Maximum number of possible entries in SigRl used by reference 35 #define MAX_SIGRL_ENTRIES ((SIZE_T_MAX - MIN_SIGRL_SIZE) / sizeof(SigRlEntry)) 36 37 /// Maximum space needed to store SigRl data in context 38 #define SIGRL_HEAP_SIZE (0) 39 40 #else // !defined(USE_SIGRL_BY_REFERENCE) 41 42 #ifndef MAX_SIGRL_ENTRIES 43 /// Maximum number of possible entries in SigRl copied by value 44 #define MAX_SIGRL_ENTRIES (5) 45 #endif 46 47 /// Maximum space needed to store SigRl data in context 48 #define SIGRL_HEAP_SIZE \ 49 (MIN_SIGRL_SIZE + MAX_SIGRL_ENTRIES * sizeof(SigRlEntry)) 50 51 #endif // !defined(USE_SIGRL_BY_REFERENCE) 52 53 #ifndef MAX_ALLOWED_BASENAMES 54 /// Maximum number of allowed base names 55 #define MAX_ALLOWED_BASENAMES (5) 56 #endif 57 58 /// Member context definition 59 typedef struct MemberCtx { 60 GroupPubKey pub_key; ///< group public key 61 HashAlg hash_alg; ///< Hash algorithm to use 62 MembershipCredential credential; ///< Membership credential 63 FpElem f; ///< secret f value 64 NativeMemberPrecomp precomp; ///< Precomputed pairing values 65 PairingState pairing_state; ///< pairing state 66 int f_is_set; ///< f initialized 67 int is_provisioned; ///< member fully provisioned with key material 68 BitSupplier rnd_func; ///< Pseudo random number generation function 69 void* rnd_param; ///< Pointer to user context for rnd_func 70 AllowedBasenames* allowed_basenames; ///< Allowed basenames 71 SigRl* sig_rl; ///< Pointer to Signature based revocation list 72 unsigned char heap[1]; ///< Bulk storage space (flexible array) 73 } MemberCtx; 74 75 #endif // EPID_MEMBER_TINY_SRC_CONTEXT_H_ 76