~ubuntu-branches/ubuntu/karmic/trousers/karmic

« back to all changes in this revision

Viewing changes to src/tspi/rpc/tcstp/rpc_auth.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 <string.h>
 
14
#include <assert.h>
 
15
 
 
16
#include "trousers/tss.h"
 
17
#include "trousers/trousers.h"
 
18
#include "trousers_types.h"
 
19
#include "spi_utils.h"
 
20
#include "capabilities.h"
 
21
#include "tsplog.h"
 
22
#include "hosttable.h"
 
23
#include "tcsd_wrap.h"
 
24
#include "obj.h"
 
25
#include "rpc_tcstp_tsp.h"
 
26
 
 
27
 
 
28
TSS_RESULT
 
29
RPC_OIAP_TP(struct host_table_entry *hte,
 
30
                         TCS_AUTHHANDLE * authHandle,   /* out */
 
31
                         TCPA_NONCE * nonce0    /* out */
 
32
    ) {
 
33
        TSS_RESULT result;
 
34
 
 
35
        initData(&hte->comm, 1);
 
36
        hte->comm.hdr.u.ordinal = TCSD_ORD_OIAP;
 
37
        LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
 
38
 
 
39
        if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
 
40
                return TSPERR(TSS_E_INTERNAL_ERROR);
 
41
 
 
42
        result = sendTCSDPacket(hte);
 
43
 
 
44
        if (result == TSS_SUCCESS)
 
45
                result = hte->comm.hdr.u.result;
 
46
 
 
47
        if (result == TSS_SUCCESS) {
 
48
                if (getData(TCSD_PACKET_TYPE_UINT32, 0, authHandle, 0, &hte->comm))
 
49
                        result = TSPERR(TSS_E_INTERNAL_ERROR);
 
50
                if (getData(TCSD_PACKET_TYPE_NONCE, 1, nonce0, 0, &hte->comm))
 
51
                        result = TSPERR(TSS_E_INTERNAL_ERROR);
 
52
        }
 
53
 
 
54
        return result;
 
55
}
 
56
 
 
57
TSS_RESULT
 
58
RPC_OSAP_TP(struct host_table_entry *hte,
 
59
                         TCPA_ENTITY_TYPE entityType,   /* in */
 
60
                         UINT32 entityValue,    /* in */
 
61
                         TCPA_NONCE * nonceOddOSAP,     /* in */
 
62
                         TCS_AUTHHANDLE * authHandle,   /* out */
 
63
                         TCPA_NONCE * nonceEven,        /* out */
 
64
                         TCPA_NONCE * nonceEvenOSAP     /* out */
 
65
    ) {
 
66
        TSS_RESULT result;
 
67
 
 
68
        initData(&hte->comm, 4);
 
69
        hte->comm.hdr.u.ordinal = TCSD_ORD_OSAP;
 
70
        LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
 
71
 
 
72
        if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
 
73
                return TSPERR(TSS_E_INTERNAL_ERROR);
 
74
        if (setData(TCSD_PACKET_TYPE_UINT16, 1, &entityType, 0, &hte->comm))
 
75
                return TSPERR(TSS_E_INTERNAL_ERROR);
 
76
        if (setData(TCSD_PACKET_TYPE_UINT32, 2, &entityValue, 0, &hte->comm))
 
77
                return TSPERR(TSS_E_INTERNAL_ERROR);
 
78
        if (setData(TCSD_PACKET_TYPE_NONCE, 3, nonceOddOSAP, 0, &hte->comm))
 
79
                return TSPERR(TSS_E_INTERNAL_ERROR);
 
80
 
 
81
        result = sendTCSDPacket(hte);
 
82
 
 
83
        if (result == TSS_SUCCESS)
 
84
                result = hte->comm.hdr.u.result;
 
85
 
 
86
        if (result == TSS_SUCCESS) {
 
87
                if (getData(TCSD_PACKET_TYPE_UINT32, 0, authHandle, 0, &hte->comm))
 
88
                        result = TSPERR(TSS_E_INTERNAL_ERROR);
 
89
                if (getData(TCSD_PACKET_TYPE_NONCE, 1, nonceEven, 0, &hte->comm))
 
90
                        result = TSPERR(TSS_E_INTERNAL_ERROR);
 
91
                if (getData(TCSD_PACKET_TYPE_NONCE, 2, nonceEvenOSAP, 0, &hte->comm))
 
92
                        result = TSPERR(TSS_E_INTERNAL_ERROR);
 
93
        }
 
94
 
 
95
        return result;
 
96
}