1 /********************************************************************************/ 2 /* */ 3 /* TSS Primary API */ 4 /* Written by Ken Goldman */ 5 /* IBM Thomas J. Watson Research Center */ 6 /* */ 7 /* (c) Copyright IBM Corporation 2015 - 2019. */ 8 /* */ 9 /* All rights reserved. */ 10 /* */ 11 /* Redistribution and use in source and binary forms, with or without */ 12 /* modification, are permitted provided that the following conditions are */ 13 /* met: */ 14 /* */ 15 /* Redistributions of source code must retain the above copyright notice, */ 16 /* this list of conditions and the following disclaimer. */ 17 /* */ 18 /* Redistributions in binary form must reproduce the above copyright */ 19 /* notice, this list of conditions and the following disclaimer in the */ 20 /* documentation and/or other materials provided with the distribution. */ 21 /* */ 22 /* Neither the names of the IBM Corporation nor the names of its */ 23 /* contributors may be used to endorse or promote products derived from */ 24 /* this software without specific prior written permission. */ 25 /* */ 26 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ 27 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ 28 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ 29 /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ 30 /* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ 31 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ 32 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ 33 /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ 34 /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ 35 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ 36 /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 37 /********************************************************************************/ 38 39 #ifndef TSS_H 40 #define TSS_H 41 42 #include <ibmtss/TPM_Types.h> 43 #include <ibmtss/Parameters.h> 44 #include <ibmtss/Parameters12.h> 45 46 /* include this as a convenience to applications */ 47 #include <ibmtss/tsserror.h> 48 #include <ibmtss/tssprint.h> 49 50 typedef struct TSS_CONTEXT TSS_CONTEXT; 51 52 #define TPM_TRACE_LEVEL 1 53 #define TPM_DATA_DIR 2 54 #define TPM_COMMAND_PORT 3 55 #define TPM_PLATFORM_PORT 4 56 #define TPM_SERVER_NAME 5 57 #define TPM_INTERFACE_TYPE 6 58 #define TPM_DEVICE 7 59 #define TPM_ENCRYPT_SESSIONS 8 60 #define TPM_SERVER_TYPE 9 61 62 #ifdef __cplusplus 63 extern "C" { 64 #endif 65 66 /* extra parameters as required */ 67 68 /* TPM 2.0 */ 69 70 typedef struct { 71 const char *bindPassword; 72 TPM2B_DIGEST salt; 73 } StartAuthSession_Extra; 74 75 typedef union { 76 StartAuthSession_Extra StartAuthSession; 77 } EXTRA_PARAMETERS; 78 79 /* TPM 1.2 */ 80 81 typedef struct { 82 const char *usagePassword; 83 } OSAP_Extra; 84 85 typedef union { 86 OSAP_Extra OSAP; 87 } EXTRA12_PARAMETERS; 88 89 LIB_EXPORT 90 TPM_RC TSS_Create(TSS_CONTEXT **tssContext); 91 92 LIB_EXPORT 93 TPM_RC TSS_Delete(TSS_CONTEXT *tssContext); 94 95 LIB_EXPORT 96 TPM_RC TSS_Execute(TSS_CONTEXT *tssContext, 97 RESPONSE_PARAMETERS *out, 98 COMMAND_PARAMETERS *in, 99 EXTRA_PARAMETERS *extra, 100 TPM_CC commandCode, 101 ...); 102 103 LIB_EXPORT 104 TPM_RC TSS_SetProperty(TSS_CONTEXT *tssContext, 105 int property, 106 const char *value); 107 108 #ifdef __cplusplus 109 } 110 #endif 111 112 #endif 113