~ubuntu-branches/ubuntu/hardy/trousers/hardy-proposed

« back to all changes in this revision

Viewing changes to src/tcs/rpc/tcstp/rpc_dir.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-01-23 22:03:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080123220300-fhtqja3c0oq0gp6z
Tags: 0.3.1-4
* Added patch from Aaron M. Ucko <ucko@debian.org> to allow trousers to
  build successfully on amd64, and presumably also other 64-bit
  architectures (Closes: #457400).
* Including udev rule for /dev/tpm from William Lima
  <wlima.amadeus@gmail.com> as suggested by David Smith <dds@google.com>
  (Closes: #459682).
* Added lintian overrides.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
30
TSS_RESULT
 
31
tcs_wrap_DirWriteAuth(struct tcsd_thread_data *data)
 
32
{
 
33
        TSS_RESULT result;
 
34
        TSS_HCONTEXT hContext;
 
35
        TCPA_DIRINDEX dirIndex;
 
36
        TCPA_DIGEST dirDigest;
 
37
        TPM_AUTH auth;
 
38
 
 
39
        if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
 
40
                return TCSERR(TSS_E_INTERNAL_ERROR);
 
41
 
 
42
        LogDebugFn("thread %zd context %x", THREAD_ID, hContext);
 
43
 
 
44
        if (getData(TCSD_PACKET_TYPE_UINT32, 1, &dirIndex, 0, &data->comm))
 
45
                return TCSERR(TSS_E_INTERNAL_ERROR);
 
46
        if (getData(TCSD_PACKET_TYPE_DIGEST, 2, &dirDigest, 0, &data->comm))
 
47
                return TCSERR(TSS_E_INTERNAL_ERROR);
 
48
        if (getData(TCSD_PACKET_TYPE_AUTH, 3, &auth, 0, &data->comm))
 
49
                return TCSERR(TSS_E_INTERNAL_ERROR);
 
50
 
 
51
        MUTEX_LOCK(tcsp_lock);
 
52
 
 
53
        result = TCSP_DirWriteAuth_Internal(hContext, dirIndex, dirDigest, &auth);
 
54
 
 
55
        MUTEX_UNLOCK(tcsp_lock);
 
56
 
 
57
        if (result == TSS_SUCCESS) {
 
58
                initData(&data->comm, 1);
 
59
                if (setData(TCSD_PACKET_TYPE_AUTH, 0, &auth, 0, &data->comm)) {
 
60
                        return TCSERR(TSS_E_INTERNAL_ERROR);
 
61
                }
 
62
        } else
 
63
                initData(&data->comm, 0);
 
64
 
 
65
        data->comm.hdr.u.result = result;
 
66
 
 
67
        return TSS_SUCCESS;
 
68
}
 
69
 
 
70
TSS_RESULT
 
71
tcs_wrap_DirRead(struct tcsd_thread_data *data)
 
72
{
 
73
        TSS_RESULT result;
 
74
        TSS_HCONTEXT hContext;
 
75
        TCPA_DIRINDEX dirIndex;
 
76
        TCPA_DIRVALUE dirValue;
 
77
 
 
78
        if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
 
79
                return TCSERR(TSS_E_INTERNAL_ERROR);
 
80
 
 
81
        LogDebugFn("thread %zd context %x", THREAD_ID, hContext);
 
82
 
 
83
        if (getData(TCSD_PACKET_TYPE_UINT32, 1, &dirIndex, 0, &data->comm))
 
84
                return TCSERR(TSS_E_INTERNAL_ERROR);
 
85
 
 
86
        MUTEX_LOCK(tcsp_lock);
 
87
 
 
88
        result = TCSP_DirRead_Internal(hContext, dirIndex, &dirValue);
 
89
 
 
90
        MUTEX_UNLOCK(tcsp_lock);
 
91
 
 
92
        if (result == TSS_SUCCESS) {
 
93
                initData(&data->comm, 1);
 
94
                if (setData(TCSD_PACKET_TYPE_DIGEST, 0, &dirValue, 0, &data->comm)) {
 
95
                        return TCSERR(TSS_E_INTERNAL_ERROR);
 
96
                }
 
97
        } else
 
98
                initData(&data->comm, 0);
 
99
 
 
100
        data->comm.hdr.u.result = result;
 
101
 
 
102
        return TSS_SUCCESS;
 
103
}