1 /* Microsoft Reference Implementation for TPM 2.0 2 * 3 * The copyright in this software is being made available under the BSD License, 4 * included below. This software may be subject to other third party and 5 * contributor rights, including patent rights, and no such rights are granted 6 * under this license. 7 * 8 * Copyright (c) Microsoft Corporation 9 * 10 * All rights reserved. 11 * 12 * BSD License 13 * 14 * Redistribution and use in source and binary forms, with or without modification, 15 * are permitted provided that the following conditions are met: 16 * 17 * Redistributions of source code must retain the above copyright notice, this list 18 * of conditions and the following disclaimer. 19 * 20 * Redistributions in binary form must reproduce the above copyright notice, this 21 * list of conditions and the following disclaimer in the documentation and/or 22 * other materials provided with the distribution. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 //** Introduction 36 37 // TPM commands are communicated as uint8_t streams on a TCP connection. The TPM 38 // command protocol is enveloped with the interface protocol described in this 39 // file. The command is indicated by a uint32 with one of the values below. Most 40 // commands take no parameters return no TPM errors. In these cases the TPM 41 // interface protocol acknowledges that command processing is completed by returning 42 // a uint32=0. The command TPM_SIGNAL_HASH_DATA takes a uint32-prepended variable 43 // length byte array and the interface protocol acknowledges command completion 44 // with a uint32=0. Most TPM commands are enveloped using the TPM_SEND_COMMAND 45 // interface command. The parameters are as indicated below. The interface layer 46 // also appends a UIN32=0 to the TPM response for regularity. 47 48 49 //** Typedefs and Defines 50 #ifndef TCP_TPM_PROTOCOL_H 51 #define TCP_TPM_PROTOCOL_H 52 53 //** TPM Commands. 54 // All commands acknowledge processing by returning a uint32 == 0 except where noted 55 #define TPM_SIGNAL_POWER_ON 1 56 #define TPM_SIGNAL_POWER_OFF 2 57 #define TPM_SIGNAL_PHYS_PRES_ON 3 58 #define TPM_SIGNAL_PHYS_PRES_OFF 4 59 #define TPM_SIGNAL_HASH_START 5 60 #define TPM_SIGNAL_HASH_DATA 6 61 // {uint32_t BufferSize, uint8_t[BufferSize] Buffer} 62 #define TPM_SIGNAL_HASH_END 7 63 #define TPM_SEND_COMMAND 8 64 // {uint8_t Locality, uint32_t InBufferSize, uint8_t[InBufferSize] InBuffer} -> 65 // {uint32_t OutBufferSize, uint8_t[OutBufferSize] OutBuffer} 66 67 #define TPM_SIGNAL_CANCEL_ON 9 68 #define TPM_SIGNAL_CANCEL_OFF 10 69 #define TPM_SIGNAL_NV_ON 11 70 #define TPM_SIGNAL_NV_OFF 12 71 #define TPM_SIGNAL_KEY_CACHE_ON 13 72 #define TPM_SIGNAL_KEY_CACHE_OFF 14 73 74 #define TPM_REMOTE_HANDSHAKE 15 75 #define TPM_SET_ALTERNATIVE_RESULT 16 76 77 #define TPM_SIGNAL_RESET 17 78 #define TPM_SIGNAL_RESTART 18 79 80 #define TPM_SESSION_END 20 81 #define TPM_STOP 21 82 83 #define TPM_GET_COMMAND_RESPONSE_SIZES 25 84 85 #define TPM_ACT_GET_SIGNALED 26 86 87 #define TPM_TEST_FAILURE_MODE 30 88 89 //** Enumerations and Structures 90 enum TpmEndPointInfo 91 { 92 tpmPlatformAvailable = 0x01, 93 tpmUsesTbs = 0x02, 94 tpmInRawMode = 0x04, 95 tpmSupportsPP = 0x08 96 }; 97 98 #ifdef _MSC_VER 99 # pragma warning(push, 3) 100 #endif 101 102 // Existing RPC interface type definitions retained so that the implementation 103 // can be re-used 104 typedef struct in_buffer 105 { 106 unsigned long BufferSize; 107 unsigned char *Buffer; 108 } _IN_BUFFER; 109 110 typedef unsigned char *_OUTPUT_BUFFER; 111 112 typedef struct out_buffer 113 { 114 uint32_t BufferSize; 115 _OUTPUT_BUFFER Buffer; 116 } _OUT_BUFFER; 117 118 #ifdef _MSC_VER 119 # pragma warning(pop) 120 #endif 121 122 #ifndef WIN32 123 typedef unsigned long DWORD; 124 typedef void *LPVOID; 125 #endif 126 127 #endif 128