rpc_auth.c revision 1.1.1.1.4.2
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-2006 8 * 9 */ 10 11#include <stdlib.h> 12#include <stdio.h> 13#include <syslog.h> 14#include <string.h> 15#include <netdb.h> 16 17#include "trousers/tss.h" 18#include "trousers_types.h" 19#include "tcs_tsp.h" 20#include "tcs_utils.h" 21#include "tcs_int_literals.h" 22#include "capabilities.h" 23#include "tcslog.h" 24#include "tcsd_wrap.h" 25#include "tcsd.h" 26#include "tcs_utils.h" 27#include "rpc_tcstp_tcs.h" 28 29 30TSS_RESULT 31tcs_wrap_OIAP(struct tcsd_thread_data *data) 32{ 33 TCS_CONTEXT_HANDLE hContext; 34 TCS_AUTHHANDLE authHandle; 35 TCPA_NONCE n0; 36 TSS_RESULT result; 37 38 if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm)) 39 return TCSERR(TSS_E_INTERNAL_ERROR); 40 41 LogDebugFn("thread %ld context %x", THREAD_ID, hContext); 42 43 MUTEX_LOCK(tcsp_lock); 44 45 result = auth_mgr_oiap(hContext, &authHandle, &n0); 46 47 MUTEX_UNLOCK(tcsp_lock); 48 49 if (result == TSS_SUCCESS) { 50 initData(&data->comm, 2); 51 if (setData(TCSD_PACKET_TYPE_UINT32, 0, &authHandle, 0, &data->comm)) { 52 return TCSERR(TSS_E_INTERNAL_ERROR); 53 } 54 if (setData(TCSD_PACKET_TYPE_NONCE, 1, &n0, 0, &data->comm)) { 55 return TCSERR(TSS_E_INTERNAL_ERROR); 56 } 57 } else 58 initData(&data->comm, 0); 59 60 data->comm.hdr.u.result = result; 61 return TSS_SUCCESS; 62} 63 64TSS_RESULT 65tcs_wrap_OSAP(struct tcsd_thread_data *data) 66{ 67 TCS_CONTEXT_HANDLE hContext; 68 TCPA_ENTITY_TYPE entityType; 69 UINT32 entityValue; 70 TCPA_NONCE nonceOddOSAP; 71 72 TCS_AUTHHANDLE authHandle; 73 TCPA_NONCE nonceEven; 74 TCPA_NONCE nonceEvenOSAP; 75 TSS_RESULT result; 76 77 if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm)) 78 return TCSERR(TSS_E_INTERNAL_ERROR); 79 80 LogDebugFn("thread %ld context %x", THREAD_ID, hContext); 81 82 if (getData(TCSD_PACKET_TYPE_UINT16, 1, &entityType, 0, &data->comm)) 83 return TCSERR(TSS_E_INTERNAL_ERROR); 84 if (getData(TCSD_PACKET_TYPE_UINT32, 2, &entityValue, 0, &data->comm)) 85 return TCSERR(TSS_E_INTERNAL_ERROR); 86 if (getData(TCSD_PACKET_TYPE_NONCE, 3, &nonceOddOSAP, 0, &data->comm)) 87 return TCSERR(TSS_E_INTERNAL_ERROR); 88 89 MUTEX_LOCK(tcsp_lock); 90 91 result = auth_mgr_osap(hContext, entityType, entityValue, nonceOddOSAP, 92 &authHandle, &nonceEven, &nonceEvenOSAP); 93 94 MUTEX_UNLOCK(tcsp_lock); 95 96 if (result == TSS_SUCCESS) { 97 initData(&data->comm, 3); 98 if (setData(TCSD_PACKET_TYPE_UINT32, 0, &authHandle, 0, &data->comm)) { 99 return TCSERR(TSS_E_INTERNAL_ERROR); 100 } 101 if (setData(TCSD_PACKET_TYPE_NONCE, 1, &nonceEven, 0, &data->comm)) { 102 return TCSERR(TSS_E_INTERNAL_ERROR); 103 } 104 if (setData(TCSD_PACKET_TYPE_NONCE, 2, &nonceEvenOSAP, 0, &data->comm)) { 105 return TCSERR(TSS_E_INTERNAL_ERROR); 106 } 107 } else 108 initData(&data->comm, 0); 109 110 data->comm.hdr.u.result = result; 111 112 return TSS_SUCCESS; 113} 114