~ubuntu-branches/ubuntu/jaunty/trousers/jaunty

« back to all changes in this revision

Viewing changes to src/tspi/tsp_get_flags.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
 
 
12
#include <stdlib.h>
 
13
#include <stdio.h>
 
14
#include <string.h>
 
15
#include <unistd.h>
 
16
#include <sys/types.h>
 
17
#include <sys/mman.h>
 
18
#include <errno.h>
 
19
 
 
20
#include "trousers/tss.h"
 
21
#include "trousers/trousers.h"
 
22
#include "trousers_types.h"
 
23
#include "trousers_types.h"
 
24
#include "spi_utils.h"
 
25
#include "capabilities.h"
 
26
#include "tsplog.h"
 
27
#include "obj.h"
 
28
 
 
29
 
 
30
TSS_RESULT
 
31
get_tpm_flags(TSS_HCONTEXT tspContext, TSS_HTPM hTPM, UINT32 *volFlags, UINT32 *nonVolFlags)
 
32
{
 
33
        TCPA_DIGEST digest;
 
34
        TPM_AUTH auth;
 
35
        TCPA_VERSION version;
 
36
        TSS_RESULT result;
 
37
        TSS_HPOLICY hPolicy;
 
38
        Trspi_HashCtx hashCtx;
 
39
 
 
40
        if ((result = obj_tpm_get_policy(hTPM, TSS_POLICY_USAGE, &hPolicy)))
 
41
                return result;
 
42
 
 
43
        /* do an owner authorized get capability call */
 
44
        result = Trspi_HashInit(&hashCtx, TSS_HASH_SHA1);
 
45
        result |= Trspi_Hash_UINT32(&hashCtx, TPM_ORD_GetCapabilityOwner);
 
46
        if ((result |= Trspi_HashFinal(&hashCtx, digest.digest)))
 
47
                return result;
 
48
 
 
49
        if ((result = secret_PerformAuth_OIAP(hTPM, TPM_ORD_GetCapabilityOwner, hPolicy, FALSE,
 
50
                                              &digest, &auth)))
 
51
                return result;
 
52
 
 
53
        if ((result = TCS_API(tspContext)->GetCapabilityOwner(tspContext, &auth, &version,
 
54
                                                              nonVolFlags, volFlags)))
 
55
                return result;
 
56
 
 
57
        result = Trspi_HashInit(&hashCtx, TSS_HASH_SHA1);
 
58
        result |= Trspi_Hash_UINT32(&hashCtx, result);
 
59
        result |= Trspi_Hash_UINT32(&hashCtx, TPM_ORD_GetCapabilityOwner);
 
60
        result |= Trspi_Hash_VERSION(&hashCtx, (TSS_VERSION *)&version);
 
61
        result |= Trspi_Hash_UINT32(&hashCtx, *nonVolFlags);
 
62
        result |= Trspi_Hash_UINT32(&hashCtx, *volFlags);
 
63
        if ((result |= Trspi_HashFinal(&hashCtx, digest.digest)))
 
64
                return result;
 
65
 
 
66
        return obj_policy_validate_auth_oiap(hPolicy, &digest, &auth);
 
67
}