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. 2004 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_OIAP_Internal(TCS_CONTEXT_HANDLE hContext, /* in */ 32 TCS_AUTHHANDLE *authHandle, /* out */ 33 TCPA_NONCE *nonce0) /* out */ 34{ 35 UINT64 offset = 0; 36 TSS_RESULT result; 37 UINT32 paramSize; 38 BYTE txBlob[TSS_TPM_TXBLOB_SIZE]; 39 40 LogDebug("Entering TCSI_OIAP"); 41 42 if ((result = ctx_verify_context(hContext))) 43 return result; 44 45 if ((result = tpm_rqu_build(TPM_ORD_OIAP, &offset, txBlob, NULL))) 46 return result; 47 48 if ((result = req_mgr_submit_req(txBlob))) 49 return result; 50 51 result = UnloadBlob_Header(txBlob, ¶mSize); 52 if (!result) { 53 result = tpm_rsp_parse(TPM_ORD_OIAP, txBlob, paramSize, authHandle, nonce0->nonce); 54 } 55 56 LogResult("OIAP", result); 57 return result; 58} 59 60TSS_RESULT 61TCSP_OSAP_Internal(TCS_CONTEXT_HANDLE hContext, /* in */ 62 TCPA_ENTITY_TYPE entityType, /* in */ 63 UINT32 entityValue, /* in */ 64 TCPA_NONCE nonceOddOSAP, /* in */ 65 TCS_AUTHHANDLE * authHandle, /* out */ 66 TCPA_NONCE * nonceEven, /* out */ 67 TCPA_NONCE * nonceEvenOSAP) /* out */ 68{ 69 UINT64 offset = 0; 70 TSS_RESULT result; 71 UINT32 paramSize; 72 BYTE txBlob[TSS_TPM_TXBLOB_SIZE]; 73 74 LogDebug("Entering OSAP"); 75 if ((result = ctx_verify_context(hContext))) 76 return result; 77 78 if ((result = tpm_rqu_build(TPM_ORD_OSAP, &offset, txBlob, entityType, entityValue, 79 nonceOddOSAP.nonce))) 80 return result; 81 82 if ((result = req_mgr_submit_req(txBlob))) 83 return result; 84 85 result = UnloadBlob_Header(txBlob, ¶mSize); 86 if (!result) { 87 result = tpm_rsp_parse(TPM_ORD_OSAP, txBlob, paramSize, authHandle, 88 nonceEven->nonce, nonceEvenOSAP->nonce); 89 } 90 LogResult("OSAP", result); 91 92 return result; 93} 94 95TSS_RESULT 96internal_TerminateHandle(TCS_AUTHHANDLE handle) 97{ 98 UINT64 offset = 0; 99 UINT32 paramSize; 100 TSS_RESULT result; 101 BYTE txBlob[TSS_TPM_TXBLOB_SIZE]; 102 103 if ((result = tpm_rqu_build(TPM_ORD_Terminate_Handle, &offset, txBlob, handle, NULL))) 104 return result; 105 106 if ((result = req_mgr_submit_req(txBlob))) 107 return result; 108 109 return UnloadBlob_Header(txBlob, ¶mSize); 110} 111 112