1 /* 2 * Copyright (c) 2014 Intel Corporation. 3 * 4 * Authors: 5 * Quan Xu <quan.xu@intel.com> 6 * 7 * Copyright (c) 2010-2012 United States Government, as represented by 8 * the Secretary of Defense. All rights reserved. 9 * 10 * based off of the original tools/vtpm_manager code base which is: 11 * Copyright (c) 2005/2006, Intel Corp. 12 * All rights reserved. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions 16 * are met: 17 * 18 * * Redistributions of source code must retain the above copyright 19 * notice, this list of conditions and the following disclaimer. 20 * * Redistributions in binary form must reproduce the above 21 * copyright notice, this list of conditions and the following 22 * disclaimer in the documentation and/or other materials provided 23 * with the distribution. 24 * * Neither the name of Intel Corporation nor the names of its 25 * contributors may be used to endorse or promote products derived 26 * from this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 31 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 32 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 33 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 39 * OF THE POSSIBILITY OF SUCH DAMAGE. 40 */ 41 42 #ifndef __TPM2_H__ 43 #define __TPM2_H__ 44 45 #include "tcg.h" 46 #include "tpm2_types.h" 47 48 // ------------------------------------------------------------------ 49 // TPM 2.0 Exposed API 50 // ------------------------------------------------------------------ 51 52 TPM_RC TPM2_PCR_Read(TPML_PCR_SELECTION pcrSelectionIn, 53 UINT32 *pcrUpdateCounter, 54 TPML_PCR_SELECTION *pcrSelectionOut, 55 TPML_DIGEST *pcrValues); 56 57 TPM_RC TPM2_Load(TPMI_DH_OBJECT parentHandle, 58 TPM2B_PRIVATE *inPrivate, 59 TPM2B_PUBLIC *inPublic, 60 TPM2_HANDLE *objectHandle, 61 TPM2B_NAME *name); 62 63 TPM_RC TPM2_Create(TPMI_DH_OBJECT parentHandle, 64 TPM2_Create_Params_in *in, 65 TPM2_Create_Params_out *out); 66 67 TPM_RC TPM2_CreatePrimary(TPMI_RH_HIERARCHY primaryHandle, 68 TPM2_Create_Params_in *objHandle, 69 TPM2_HANDLE *in, 70 TPM2_Create_Params_out *out); 71 72 TPM_RC TPM2_HierachyChangeAuth(TPM2I_RH_HIERARCHY_AUTH authHandle, 73 TPM2B_AUTH *newAuth); 74 75 TPM_RC TPM2_RSA_ENCRYPT(TPMI_DH_OBJECT keyHandle, 76 TPM2B_PUBLIC_KEY_RSA *message, 77 TPMT_RSA_DECRYPT *inScheme, 78 TPM2B_DATA *label, 79 TPM2B_PUBLIC_KEY_RSA *outData); 80 81 TPM_RC TPM2_Bind(TPMI_DH_OBJECT keyHandle, 82 void *buf, 83 UINT32 len, 84 void *out); 85 86 TPM_RC TPM2_RSA_Decrypt(TPMI_DH_OBJECT keyHandle, 87 TPM2B_PUBLIC_KEY_RSA *cipherText, 88 TPMT_RSA_DECRYPT *inScheme, 89 TPM2B_DATA *label, 90 TPM2B_PUBLIC_KEY_RSA *message); 91 92 TPM_RC TPM2_UnBind(TPMI_DH_OBJECT keyHandle, 93 UINT32 ilen, 94 void *in, 95 UINT32 *olen, 96 void *out); 97 98 TPM_RESULT TPM2_GetRandom(UINT32* bytesRequested, 99 BYTE* randomBytes); 100 101 TPM_RC TPM2_CLEAR(void); 102 103 TPM_RC TPM2_FlushContext(TPMI_DH_CONTEXT); 104 #endif //TPM2_H 105