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