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 17 /*! 18 * \file 19 * \brief Conversion utilities interface. 20 */ 21 #ifndef EXAMPLE_UTIL_CONVUTIL_H_ 22 #define EXAMPLE_UTIL_CONVUTIL_H_ 23 24 #include <stddef.h> 25 #include "epid/common/bitsupplier.h" 26 #include "epid/common/file_parser.h" 27 #include "epid/common/types.h" 28 #include "util/stdtypes.h" 29 #ifdef TPM_TSS 30 #include "epid/member/tpm_member.h" 31 #else 32 #include "epid/member/software_member.h" 33 #endif 34 35 /// Implementation specific configuration parameters. 36 typedef struct MemberParams MemberParams; 37 38 /// convert a hash algorithm to a string 39 /*! 40 \param[in] alg a hash algorithm 41 \returns string representing the algorithm 42 */ 43 char const* HashAlgToString(HashAlg alg); 44 45 /// convert a string to a hash algorithm 46 /*! 47 \param[in] str a string 48 \param[out] alg a hash algorithm 49 \retval true string represents a hash algorithm 50 \retval false string does not represent a hash algorithm 51 */ 52 bool StringToHashAlg(char const* str, HashAlg* alg); 53 54 /// convert an Intel(R) EPID version to a string 55 /*! 56 \param[in] version an Intel(R) EPID version 57 \returns string representing the version 58 */ 59 char const* EpidVersionToString(EpidVersion version); 60 61 /// convert a string to an Intel(R) EPID version 62 /*! 63 \param[in] str a string 64 \param[out] version an Intel(R) EPID version 65 \retval true string represents an Intel(R) EPID version 66 \retval false string does not represent an Intel(R) EPID version 67 */ 68 bool StringToEpidVersion(char const* str, EpidVersion* version); 69 70 /// convert an Intel(R) EPID file type to a string 71 /*! 72 \param[in] type an Intel(R) EPID file type 73 \returns string representing the algorithm 74 */ 75 char const* EpidFileTypeToString(EpidFileType type); 76 77 /// convert a string to an Intel(R) EPID file type 78 /*! 79 \param[in] str a string 80 \param[out] type an Intel(R) EPID file type 81 \retval true string represents an Intel(R) EPID file type 82 \retval false string does not represent an Intel(R) EPID file type 83 */ 84 bool StringToEpidFileType(char const* str, EpidFileType* type); 85 86 /// set MemberParams to encapsulate different structure of Memparams 87 /// in case of TPM mode and none TPM mode 88 /*! 89 \param[in] rnd_func a Intel(R) EPID BitSupplier 90 \param[in] rnd_param a random parameters for BitSupplier 91 \param[in] f is Intel(R) EPID FpElemStr 92 \param[out] params is Intel(R) EPID MemberParams 93 \returns void 94 */ 95 void SetMemberParams(BitSupplier rnd_func, void* rnd_param, FpElemStr* f, 96 MemberParams* params); 97 98 #endif // EXAMPLE_UTIL_CONVUTIL_H_ 99