1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/*
* Licensed Materials - Property of IBM
*
* trousers - An open source TCG Software Stack
*
* (C) Copyright International Business Machines Corp. 2004-2007
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include "trousers/tss.h"
#include "trousers/trousers.h"
#include "trousers_types.h"
#include "trousers_types.h"
#include "spi_utils.h"
#include "capabilities.h"
#include "tsplog.h"
#include "obj.h"
TSS_RESULT
Tspi_GetPolicyObject(TSS_HOBJECT hObject, /* in */
TSS_FLAG policyType, /* in */
TSS_HPOLICY * phPolicy) /* out */
{
TSS_RESULT result;
if (phPolicy == NULL)
return TSPERR(TSS_E_BAD_PARAMETER);
if (obj_is_tpm(hObject)) {
result = obj_tpm_get_policy(hObject, policyType, phPolicy);
#ifdef TSS_BUILD_NV
} else if (obj_is_nvstore(hObject)) {
result = obj_nvstore_get_policy(hObject, policyType, phPolicy);
#endif
#ifdef TSS_BUILD_RSAKEY_LIST
} else if (obj_is_rsakey(hObject)) {
result = obj_rsakey_get_policy(hObject, policyType, phPolicy, NULL);
#endif
#ifdef TSS_BUILD_ENCDATA_LIST
} else if (obj_is_encdata(hObject)) {
result = obj_encdata_get_policy(hObject, policyType, phPolicy);
#endif
} else {
if (obj_is_policy(hObject) || obj_is_hash(hObject) ||
obj_is_pcrs(hObject) || obj_is_context(hObject))
result = TSPERR(TSS_E_BAD_PARAMETER);
else
result = TSPERR(TSS_E_INVALID_HANDLE);
}
if (result == TSS_SUCCESS && *phPolicy == NULL_HPOLICY)
result = TSPERR(TSS_E_INTERNAL_ERROR);
return result;
}
TSS_RESULT
Tspi_Policy_SetSecret(TSS_HPOLICY hPolicy, /* in */
TSS_FLAG secretMode, /* in */
UINT32 ulSecretLength, /* in */
BYTE * rgbSecret) /* in */
{
TSS_RESULT result;
TSS_HCONTEXT tspContext;
if ((result = obj_policy_get_tsp_context(hPolicy, &tspContext)))
return result;
if (obj_context_is_silent(tspContext) && secretMode == TSS_SECRET_MODE_POPUP)
return TSPERR(TSS_E_SILENT_CONTEXT);
return obj_policy_set_secret(hPolicy, secretMode, ulSecretLength, rgbSecret);
}
TSS_RESULT
Tspi_Policy_FlushSecret(TSS_HPOLICY hPolicy) /* in */
{
return obj_policy_flush_secret(hPolicy);
}
TSS_RESULT
Tspi_Policy_AssignToObject(TSS_HPOLICY hPolicy, /* in */
TSS_HOBJECT hObject) /* in */
{
TSS_RESULT result;
if (obj_is_tpm(hObject)) {
result = obj_tpm_set_policy(hObject, hPolicy);
#ifdef TSS_BUILD_NV
} else if (obj_is_nvstore(hObject)) {
result = obj_nvstore_set_policy(hObject, hPolicy);
#endif
#ifdef TSS_BUILD_RSAKEY_LIST
} else if (obj_is_rsakey(hObject)) {
result = obj_rsakey_set_policy(hObject, hPolicy);
#endif
#ifdef TSS_BUILD_ENCDATA_LIST
} else if (obj_is_encdata(hObject)) {
result = obj_encdata_set_policy(hObject, hPolicy);
#endif
} else {
result = TSPERR(TSS_E_BAD_PARAMETER);
}
return result;
}
|