1 2 /* 3 * Licensed Materials - Property of IBM 4 * 5 * trousers - An open source TCG Software Stack 6 * 7 * (C) Copyright International Business Machines Corp. 2004 8 * 9 */ 10 11 12 #ifndef _TCSD_H_ 13 #define _TCSD_H_ 14 15 #include <signal.h> 16 17 #include "rpc_tcstp.h" 18 19 /* Platform Class structures */ 20 struct platform_class 21 { 22 unsigned int simpleID; /* Platform specific spec identifier */ 23 unsigned int classURISize; /* Size of the classURI */ 24 char *classURI; /* Specific spec. Can be NULL */ 25 struct platform_class *next; 26 }; 27 28 /* config structures */ 29 struct tcsd_config 30 { 31 int port; /* port the TCSD will listen on */ 32 unsigned int num_threads; /* max number of threads the TCSD allows simultaneously */ 33 char *system_ps_dir; /* the directory the system PS file sits in */ 34 char *system_ps_file; /* the name of the system PS file */ 35 char *firmware_log_file;/* the name of the firmware PCR event file */ 36 char *kernel_log_file; /* the name of the kernel PCR event file */ 37 unsigned int kernel_pcrs; /* bitmask of PCRs the kernel controls */ 38 unsigned int firmware_pcrs; /* bitmask of PCRs the firmware controls */ 39 char *platform_cred; /* location of the platform credential */ 40 char *conformance_cred; /* location of the conformance credential */ 41 char *endorsement_cred; /* location of the endorsement credential */ 42 int remote_ops[TCSD_MAX_NUM_ORDS]; /* array of ordinals executable by remote hosts */ 43 unsigned int unset; /* bitmask of options which are still unset */ 44 int exclusive_transport; /* allow applications to open exclusive transport sessions with 45 the TPM and enforce their exclusivity (possible DOS issue) */ 46 struct platform_class *host_platform_class; /* Host platform class of this TCS System */ 47 struct platform_class *all_platform_classes; /* List of platform classes 48 of this TCS System */ 49 int disable_ipv4; 50 int disable_ipv6; 51 }; 52 53 #define TCSD_DEFAULT_CONFIG_FILE ETC_PREFIX "/tcsd.conf" 54 extern char *tcsd_config_file; 55 56 #ifndef TSS_USER_NAME 57 #define TSS_USER_NAME "tss" 58 #endif 59 #ifndef TSS_GROUP_NAME 60 #define TSS_GROUP_NAME "tss" 61 #endif 62 63 #ifndef TPM_PREFIX 64 #define TPM_PREFIX "/lib/tpm" 65 #endif 66 67 #define TCSD_DEFAULT_MAX_THREADS 10 68 #define TCSD_DEFAULT_SYSTEM_PS_FILE VAR_PREFIX TPM_PREFIX "/system.data" 69 #define TCSD_DEFAULT_SYSTEM_PS_DIR VAR_PREFIX TPM_PREFIX 70 #define TCSD_DEFAULT_FIRMWARE_LOG_FILE "/var/run/tpm/binary_bios_measurements" 71 #define TCSD_DEFAULT_KERNEL_LOG_FILE "/var/run/ima/binary_runtime_measurements" 72 #define TCSD_DEFAULT_FIRMWARE_PCRS 0x00000000 73 #define TCSD_DEFAULT_KERNEL_PCRS 0x00000000 74 #define TCSD_DEFAULT_DISABLE_IPV4 0 75 #define TCSD_DEFAULT_DISABLE_IPV6 0 76 77 /* This will change when a system with more than 32 PCR's exists */ 78 #define TCSD_MAX_PCRS 32 79 80 /* this is the 2nd param passed to the listen() system call */ 81 #define TCSD_MAX_SOCKETS_QUEUED 50 82 #define TCSD_TXBUF_SIZE 1024 83 84 /* The Available Tcs Platform Classes */ 85 struct tcg_platform_spec { 86 char *name; 87 TPM_PLATFORM_SPECIFIC specNo; 88 char *specURI; 89 }; 90 91 /* The Specific URI's for the platforms specs on TCG website */ 92 #define TPM_PS_PC_11_URI "https://www.trustedcomputinggroup.org/groups/pc_client/TCG_PCSpecificSpecification_v1_1.pdf" 93 #define TPM_PS_PC_12_URI "https://www.trustedcomputinggroup.org/specs/PCClient/TCG_PCClientImplementationforBIOS_1-20_1-00.pdf" 94 #define TPM_PS_PDA_12_URI "https://www.trustedcomputinggroup.org/specs/mobilephone/tcg-mobile-reference-architecture-1.0.pdf" 95 #define TPM_PS_Server_12_URI "https://www.trustedcomputinggroup.org/specs/Server/TCG_Generic_Server_Specification_v1_0_rev0_8.pdf" 96 #define TPM_PS_Mobile_12_URI "https://www.trustedcomputinggroup.org/specs/mobilephone/tcg-mobile-reference-architecture-1.0.pdf" 97 98 /* for detecting whether an option has been set */ 99 #define TCSD_OPTION_PORT 0x0001 100 #define TCSD_OPTION_MAX_THREADS 0x0002 101 #define TCSD_OPTION_FIRMWARE_PCRS 0x0004 102 #define TCSD_OPTION_KERNEL_PCRS 0x0008 103 #define TCSD_OPTION_SYSTEM_PSFILE 0x0010 104 #define TCSD_OPTION_KERNEL_LOGFILE 0x0020 105 #define TCSD_OPTION_FIRMWARE_LOGFILE 0x0040 106 #define TCSD_OPTION_PLATFORM_CRED 0x0080 107 #define TCSD_OPTION_CONFORMANCE_CRED 0x0100 108 #define TCSD_OPTION_ENDORSEMENT_CRED 0x0200 109 #define TCSD_OPTION_REMOTE_OPS 0x0400 110 #define TCSD_OPTION_EXCLUSIVE_TRANSPORT 0x0800 111 #define TCSD_OPTION_HOST_PLATFORM_CLASS 0x1000 112 #define TCSD_OPTION_DISABLE_IPV4 0x2000 113 #define TCSD_OPTION_DISABLE_IPV6 0x4000 114 115 #define TSS_TCP_RPC_MAX_DATA_LEN 1048576 116 #define TSS_TCP_RPC_BAD_PACKET_TYPE 0x10000000 117 118 enum tcsd_config_option_code { 119 opt_port = 1, 120 opt_max_threads, 121 opt_system_ps_file, 122 opt_firmware_log, 123 opt_kernel_log, 124 opt_firmware_pcrs, 125 opt_kernel_pcrs, 126 opt_platform_cred, 127 opt_conformance_cred, 128 opt_endorsement_cred, 129 opt_remote_ops, 130 opt_exclusive_transport, 131 opt_host_platform_class, 132 opt_all_platform_classes, 133 opt_disable_ipv4, 134 opt_disable_ipv6 135 }; 136 137 struct tcsd_config_options { 138 char *name; 139 enum tcsd_config_option_code option; 140 }; 141 142 extern struct tcsd_config tcsd_options; 143 144 TSS_RESULT conf_file_init(struct tcsd_config *); 145 void conf_file_final(struct tcsd_config *); 146 TSS_RESULT ps_dirs_init(); 147 void tcsd_signal_handler(int); 148 149 /* threading structures */ 150 struct tcsd_thread_data 151 { 152 int sock; 153 UINT32 context; 154 THREAD_TYPE *thread_id; 155 char *hostname; 156 struct tcsd_comm_data comm; 157 }; 158 159 struct tcsd_thread_mgr 160 { 161 MUTEX_DECLARE(lock); 162 struct tcsd_thread_data *thread_data; 163 164 int shutdown; 165 UINT32 num_active_threads; 166 UINT32 max_threads; 167 }; 168 169 TSS_RESULT tcsd_threads_init(); 170 TSS_RESULT tcsd_threads_final(); 171 TSS_RESULT tcsd_thread_create(int, char *); 172 void *tcsd_thread_run(void *); 173 void thread_signal_init(); 174 175 #endif 176