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. 2006 8 * 9 */ 10 11 12#include <stdlib.h> 13#include <stdio.h> 14#include <string.h> 15#include <inttypes.h> 16 17#include "trousers/tss.h" 18#include "trousers_types.h" 19#include "tcs_tsp.h" 20#include "tcsps.h" 21#include "tcs_utils.h" 22#include "tcs_int_literals.h" 23#include "capabilities.h" 24#include "tcslog.h" 25#include "req_mgr.h" 26#include "tcsd_wrap.h" 27#include "tcsd.h" 28 29 30TSS_RESULT 31TCSP_Quote_Internal(TCS_CONTEXT_HANDLE hContext, /* in */ 32 TCS_KEY_HANDLE keyHandle, /* in */ 33 TCPA_NONCE antiReplay, /* in */ 34 UINT32 pcrDataSizeIn, /* in */ 35 BYTE * pcrDataIn, /* in */ 36 TPM_AUTH * privAuth, /* in, out */ 37 UINT32 * pcrDataSizeOut, /* out */ 38 BYTE ** pcrDataOut, /* out */ 39 UINT32 * sigSize, /* out */ 40 BYTE ** sig) /* out */ 41{ 42 43 UINT64 offset = 0; 44 UINT32 paramSize; 45 TSS_RESULT result; 46 UINT32 keySlot; 47 BYTE txBlob[TSS_TPM_TXBLOB_SIZE]; 48 49 LogDebug("Entering quote"); 50 51 if ((result = ctx_verify_context(hContext))) 52 goto done; 53 54 if (privAuth != NULL) { 55 LogDebug("Auth Used"); 56 if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle))) 57 goto done; 58 } else { 59 LogDebug("No Auth"); 60 } 61 if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot))) 62 goto done; 63 64 if ((result = tpm_rqu_build(TPM_ORD_Quote, &offset, txBlob, keySlot, antiReplay.nonce, 65 pcrDataSizeIn, pcrDataIn, privAuth))) 66 goto done; 67 68 if ((result = req_mgr_submit_req(txBlob))) 69 goto done; 70 71 result = UnloadBlob_Header(txBlob, ¶mSize); 72 if (!result) { 73 result = tpm_rsp_parse(TPM_ORD_Quote, txBlob, paramSize, pcrDataSizeOut, pcrDataOut, 74 sigSize, sig, privAuth); 75 } 76 LogResult("Quote", result); 77done: 78 auth_mgr_release_auth(privAuth, NULL, hContext); 79 return result; 80} 81 82