[34] | 1 | // =================================================================== |
---|
| 2 | // |
---|
| 3 | // Copyright (c) 2005, Intel Corp. |
---|
| 4 | // All rights reserved. |
---|
| 5 | // |
---|
| 6 | // Redistribution and use in source and binary forms, with or without |
---|
| 7 | // modification, are permitted provided that the following conditions |
---|
| 8 | // are met: |
---|
| 9 | // |
---|
| 10 | // * Redistributions of source code must retain the above copyright |
---|
| 11 | // notice, this list of conditions and the following disclaimer. |
---|
| 12 | // * Redistributions in binary form must reproduce the above |
---|
| 13 | // copyright notice, this list of conditions and the following |
---|
| 14 | // disclaimer in the documentation and/or other materials provided |
---|
| 15 | // with the distribution. |
---|
| 16 | // * Neither the name of Intel Corporation nor the names of its |
---|
| 17 | // contributors may be used to endorse or promote products derived |
---|
| 18 | // from this software without specific prior written permission. |
---|
| 19 | // |
---|
| 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
| 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
| 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
---|
| 23 | // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
---|
| 24 | // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
---|
| 25 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
---|
| 26 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
---|
| 27 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
| 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
---|
| 29 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
---|
| 31 | // OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | // =================================================================== |
---|
| 33 | // |
---|
| 34 | // tcs.h |
---|
| 35 | // |
---|
| 36 | // This file declares the TCS API |
---|
| 37 | // |
---|
| 38 | // ================================================================== |
---|
| 39 | |
---|
| 40 | #ifndef __TCS_H__ |
---|
| 41 | #define __TCS_H__ |
---|
| 42 | |
---|
| 43 | #include "tcg.h" |
---|
| 44 | #include "contextmgr.h" |
---|
| 45 | #include "buffer.h" |
---|
| 46 | |
---|
| 47 | #define HANDLE_NULL 0 |
---|
| 48 | |
---|
| 49 | // ------------------------------------------------------------------ |
---|
| 50 | // Exposed API |
---|
| 51 | // ------------------------------------------------------------------ |
---|
| 52 | |
---|
| 53 | TPM_RESULT TCS_create(); |
---|
| 54 | void TCS_destroy(); |
---|
| 55 | |
---|
| 56 | TPM_RESULT TCS_OpenContext( /* OUT */ TCS_CONTEXT_HANDLE* hContext ); |
---|
| 57 | |
---|
| 58 | TPM_RESULT TCS_CloseContext ( /* IN */ TCS_CONTEXT_HANDLE hContext ); |
---|
| 59 | |
---|
| 60 | TPM_RESULT TCS_Malloc ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 61 | UINT32 MemSize, // in |
---|
| 62 | BYTE** ppMemPtr ); //out |
---|
| 63 | |
---|
| 64 | TPM_RESULT TCS_FreeMemory ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 65 | BYTE* pMemory); // in |
---|
| 66 | |
---|
| 67 | // ------------------------------------------------------------------ |
---|
| 68 | // Exposed API |
---|
| 69 | // ------------------------------------------------------------------ |
---|
| 70 | |
---|
| 71 | // TPM v1.1B Command Set |
---|
| 72 | |
---|
| 73 | // Authorzation |
---|
| 74 | TPM_RESULT TCSP_OIAP( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 75 | TCS_AUTHHANDLE* authHandle, // out |
---|
| 76 | TPM_NONCE* nonce0 // out |
---|
| 77 | ); |
---|
| 78 | |
---|
| 79 | TPM_RESULT TCSP_OSAP ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 80 | TPM_ENTITY_TYPE entityType, // in |
---|
| 81 | UINT32 entityValue, // in |
---|
| 82 | TPM_NONCE nonceOddOSAP, // in |
---|
| 83 | TCS_AUTHHANDLE* authHandle, // out |
---|
| 84 | TPM_NONCE* nonceEven, // out |
---|
| 85 | TPM_NONCE* nonceEvenOSAP // out |
---|
| 86 | ); |
---|
| 87 | |
---|
| 88 | TPM_RESULT TCSP_TakeOwnership ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 89 | UINT16 protocolID, // in |
---|
| 90 | UINT32 encOwnerAuthSize, // in |
---|
| 91 | BYTE* encOwnerAuth, // in |
---|
| 92 | UINT32 encSrkAuthSize, // in |
---|
| 93 | BYTE* encSrkAuth, // in |
---|
| 94 | UINT32* SrkSize, // in, out |
---|
| 95 | BYTE** Srk, // in, out |
---|
| 96 | TCS_AUTH* ownerAuth // in, out |
---|
| 97 | ); |
---|
| 98 | |
---|
| 99 | TPM_RESULT TCSP_DisablePubekRead ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 100 | TCS_AUTH* ownerAuth // in, out |
---|
| 101 | ); |
---|
| 102 | |
---|
| 103 | TPM_RESULT TCSP_TerminateHandle ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 104 | TCS_AUTHHANDLE handle // in |
---|
| 105 | ); |
---|
| 106 | |
---|
| 107 | TPM_RESULT TCSP_FlushSpecific ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 108 | TCS_AUTHHANDLE handle, // in |
---|
| 109 | TPM_RESOURCE_TYPE resourceType //in |
---|
| 110 | ); |
---|
| 111 | |
---|
| 112 | // TPM Mandatory |
---|
| 113 | TPM_RESULT TCSP_Extend ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 114 | TPM_PCRINDEX pcrNum, // in |
---|
| 115 | TPM_DIGEST inDigest, // in |
---|
| 116 | TPM_PCRVALUE* outDigest // out |
---|
| 117 | ); |
---|
| 118 | |
---|
| 119 | TPM_RESULT TCSP_PcrRead ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 120 | TPM_PCRINDEX pcrNum, // in |
---|
| 121 | TPM_PCRVALUE* outDigest // out |
---|
| 122 | ); |
---|
| 123 | |
---|
| 124 | TPM_RESULT TCSP_Quote ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 125 | TCS_KEY_HANDLE keyHandle, // in |
---|
| 126 | TPM_NONCE antiReplay, // in |
---|
| 127 | UINT32* PcrDataSize, // in, out |
---|
| 128 | BYTE** PcrData, // in, out |
---|
| 129 | TCS_AUTH* privAuth, // in, out |
---|
| 130 | UINT32* sigSize, // out |
---|
| 131 | BYTE** sig // out |
---|
| 132 | ); |
---|
| 133 | |
---|
| 134 | TPM_RESULT TCSP_Seal ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 135 | TCS_KEY_HANDLE keyHandle, // in |
---|
| 136 | TPM_ENCAUTH encAuth, // in |
---|
| 137 | UINT32 pcrInfoSize, // in |
---|
| 138 | BYTE* PcrInfo, // in |
---|
| 139 | UINT32 inDataSize, // in |
---|
| 140 | BYTE* inData, // in |
---|
| 141 | TCS_AUTH* pubAuth, // in, out |
---|
| 142 | UINT32* SealedDataSize, // out |
---|
| 143 | BYTE** SealedData // out |
---|
| 144 | ); |
---|
| 145 | |
---|
| 146 | TPM_RESULT TCSP_Unseal ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 147 | TCS_KEY_HANDLE parentHandle, // in |
---|
| 148 | UINT32 SealedDataSize, // in |
---|
| 149 | BYTE* SealedData, // in |
---|
| 150 | TCS_AUTH* parentAuth, // in, out |
---|
| 151 | TCS_AUTH* dataAuth, // in, out |
---|
| 152 | UINT32* DataSize, // out |
---|
| 153 | BYTE** Data // out |
---|
| 154 | ); |
---|
| 155 | |
---|
| 156 | TPM_RESULT TCSP_DirWriteAuth ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 157 | TPM_DIRINDEX dirIndex, // in |
---|
| 158 | TPM_DIRVALUE newContents, // in |
---|
| 159 | TCS_AUTH* ownerAuth // in, out |
---|
| 160 | ); |
---|
| 161 | |
---|
| 162 | TPM_RESULT TCSP_DirRead ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 163 | TPM_DIRINDEX dirIndex, // in |
---|
| 164 | TPM_DIRVALUE* dirValue // out |
---|
| 165 | ); |
---|
| 166 | |
---|
| 167 | TPM_RESULT TCSP_UnBind ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 168 | TCS_KEY_HANDLE keyHandle, // in |
---|
| 169 | UINT32 inDataSize, // in |
---|
| 170 | BYTE* inData, // in |
---|
| 171 | TCS_AUTH* privAuth, // in, out |
---|
| 172 | UINT32* outDataSize, // out |
---|
| 173 | BYTE** outData // out |
---|
| 174 | ); |
---|
| 175 | |
---|
| 176 | TPM_RESULT TCSP_CreateWrapKey ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 177 | TCS_KEY_HANDLE hWrappingKey, // in |
---|
| 178 | TPM_ENCAUTH KeyUsageAuth, // in |
---|
| 179 | TPM_ENCAUTH KeyMigrationAuth, // in |
---|
| 180 | UINT32* pcKeySize, // in, out |
---|
| 181 | BYTE** prgbKey, // in, out |
---|
| 182 | TCS_AUTH* pAuth // in, out |
---|
| 183 | ); |
---|
| 184 | |
---|
| 185 | TPM_RESULT TCSP_LoadKeyByBlob ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 186 | TCS_KEY_HANDLE hUnwrappingKey, // in |
---|
| 187 | UINT32 cWrappedKeyBlobSize, // in |
---|
| 188 | BYTE* rgbWrappedKeyBlob, // in |
---|
| 189 | TCS_AUTH* pAuth, // in, out |
---|
| 190 | TCS_KEY_HANDLE* phKeyTCSI, // out |
---|
| 191 | TCS_KEY_HANDLE* phKeyHMAC // out |
---|
| 192 | ); |
---|
| 193 | |
---|
| 194 | TPM_RESULT TCSP_GetPubKey ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 195 | TCS_KEY_HANDLE hKey, // in |
---|
| 196 | TCS_AUTH* pAuth, // in, out |
---|
| 197 | UINT32* pcPubKeySize, // out |
---|
| 198 | BYTE** prgbPubKey // out |
---|
| 199 | ); |
---|
| 200 | |
---|
| 201 | TPM_RESULT TCSP_EvictKey ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 202 | TCS_KEY_HANDLE hKey // in |
---|
| 203 | ); |
---|
| 204 | |
---|
| 205 | TPM_RESULT TCSP_Sign ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 206 | TCS_KEY_HANDLE keyHandle, // in |
---|
| 207 | UINT32 areaToSignSize, // in |
---|
| 208 | BYTE* areaToSign, // in |
---|
| 209 | TCS_AUTH* privAuth, // in, out |
---|
| 210 | UINT32* sigSize, // out |
---|
| 211 | BYTE** sig // out |
---|
| 212 | ); |
---|
| 213 | |
---|
| 214 | TPM_RESULT TCSP_GetRandom ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 215 | UINT32* bytesRequested, // in, out |
---|
| 216 | BYTE** randomBytes // out |
---|
| 217 | ); |
---|
| 218 | |
---|
| 219 | TPM_RESULT TCSP_StirRandom ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 220 | UINT32 inDataSize, // in |
---|
| 221 | BYTE* inData // in |
---|
| 222 | ); |
---|
| 223 | |
---|
| 224 | TPM_RESULT TCSP_ReadPubek ( TCS_CONTEXT_HANDLE hContext, // in |
---|
| 225 | TPM_NONCE antiReplay, // in |
---|
| 226 | UINT32* pubEndorsementKeySize, // out |
---|
| 227 | BYTE** pubEndorsementKey, // out |
---|
| 228 | TPM_DIGEST* checksum // out |
---|
| 229 | ); |
---|
| 230 | |
---|
| 231 | |
---|
| 232 | // Non-Standard TCSP calls |
---|
| 233 | TPM_RESULT TCSP_SaveState(TCS_CONTEXT_HANDLE hContext); // in |
---|
| 234 | |
---|
| 235 | //Give direct access to TransmitData. |
---|
| 236 | // Key and Auth Management is done before transfering command to TDDL. |
---|
| 237 | TPM_RESULT TCSP_RawTransmitData(UINT32 inDataSize, // in |
---|
| 238 | BYTE *inData, // in |
---|
| 239 | UINT32 *outDataSize,// in/out |
---|
| 240 | BYTE *outData); // out |
---|
| 241 | |
---|
| 242 | ///////////// Private Functions //////////////////// |
---|
| 243 | CONTEXT_HANDLE* LookupContext( TCS_CONTEXT_HANDLE hContext); |
---|
| 244 | |
---|
| 245 | #endif //TCS_H |
---|