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

« back to all changes in this revision

Viewing changes to src/tcs/tcsi_selftest.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
 
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
 
 
30
TSS_RESULT
 
31
TCSP_SelfTestFull_Internal(TCS_CONTEXT_HANDLE hContext) /* in */
 
32
{
 
33
        UINT64 offset = 0;
 
34
        UINT32 paramSize;
 
35
        TSS_RESULT result;
 
36
        BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
 
37
 
 
38
        LogDebug("Entering Self Test Full");
 
39
        if ((result = ctx_verify_context(hContext)))
 
40
                return result;
 
41
 
 
42
        if ((result = tpm_rqu_build(TPM_ORD_SelfTestFull, &offset, txBlob, NULL)))
 
43
                return result;
 
44
 
 
45
        if ((result = req_mgr_submit_req(txBlob)))
 
46
                return result;
 
47
 
 
48
        result = UnloadBlob_Header(txBlob, &paramSize);
 
49
        LogResult("Self Test Full", result);
 
50
        return result;
 
51
}
 
52
 
 
53
TSS_RESULT
 
54
TCSP_CertifySelfTest_Internal(TCS_CONTEXT_HANDLE hContext,      /* in */
 
55
                              TCS_KEY_HANDLE keyHandle, /* in */
 
56
                              TCPA_NONCE antiReplay,    /* in */
 
57
                              TPM_AUTH * privAuth,      /* in, out */
 
58
                              UINT32 * sigSize, /* out */
 
59
                              BYTE ** sig)      /* out */
 
60
{
 
61
        UINT64 offset = 0;
 
62
        UINT32 paramSize;
 
63
        TSS_RESULT result;
 
64
        TCPA_KEY_HANDLE keySlot;
 
65
        BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
 
66
 
 
67
        LogDebug("Entering Certify Self Test");
 
68
 
 
69
        if ((result = ctx_verify_context(hContext)))
 
70
                goto done;
 
71
 
 
72
        if (privAuth != NULL) {
 
73
                LogDebug("Auth Used");
 
74
                if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
 
75
                        goto done;
 
76
        } else {
 
77
                LogDebug("No Auth");
 
78
        }
 
79
 
 
80
        if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
 
81
                goto done;
 
82
 
 
83
        if ((result = tpm_rqu_build(TPM_ORD_CertifySelfTest, &offset, txBlob, keySlot,
 
84
                                    TPM_NONCE_SIZE, antiReplay.nonce, privAuth, NULL)))
 
85
                return result;
 
86
 
 
87
        if ((result = req_mgr_submit_req(txBlob)))
 
88
                goto done;
 
89
 
 
90
        result = UnloadBlob_Header(txBlob, &paramSize);
 
91
        if (!result) {
 
92
                result = tpm_rsp_parse(TPM_ORD_CertifySelfTest, txBlob, paramSize, sigSize, sig,
 
93
                                       privAuth, NULL);
 
94
        }
 
95
        LogResult("Certify Self Test", result);
 
96
done:
 
97
        auth_mgr_release_auth(privAuth, NULL, hContext);
 
98
        return result;
 
99
}
 
100
 
 
101
TSS_RESULT
 
102
TCSP_GetTestResult_Internal(TCS_CONTEXT_HANDLE hContext,        /* in */
 
103
                            UINT32 * outDataSize,       /* out */
 
104
                            BYTE ** outData)    /* out */
 
105
{
 
106
        TSS_RESULT result;
 
107
        UINT32 paramSize;
 
108
        UINT64 offset = 0;
 
109
        BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
 
110
 
 
111
        LogDebug("Entering Get Test Result");
 
112
        if ((result = ctx_verify_context(hContext)))
 
113
                return result;
 
114
 
 
115
        if ((result = tpm_rqu_build(TPM_ORD_GetTestResult, &offset, txBlob, NULL)))
 
116
                return result;
 
117
 
 
118
        if ((result = req_mgr_submit_req(txBlob)))
 
119
                return result;
 
120
 
 
121
        result = UnloadBlob_Header(txBlob, &paramSize);
 
122
        if (!result) {
 
123
                result = tpm_rsp_parse(TPM_ORD_GetTestResult, txBlob, paramSize, outDataSize,
 
124
                                       outData, NULL, NULL);
 
125
        }
 
126
        LogResult("Get Test Result", result);
 
127
        return result;
 
128
}
 
129