OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 | 5 |
6 /* Test of space permissions retrieval. The spaces 0xcafe and 0xcaff must have | 6 /* Test of space permissions retrieval. |
7 * already been defined (by running, for instance, the "redefine" test). | |
8 */ | 7 */ |
9 | 8 |
10 #include <stdint.h> | 9 #include <stdint.h> |
11 #include <stdio.h> | 10 #include <stdio.h> |
12 #include <stdlib.h> | 11 #include <stdlib.h> |
13 | 12 |
14 #include "tlcl.h" | 13 #include "tlcl.h" |
| 14 #include "tlcl_tests.h" |
15 #include "utility.h" | 15 #include "utility.h" |
16 | 16 |
17 #define INDEX0 0xcafe | |
18 #define INDEX1 0xcaff | |
19 | |
20 int main(int argc, char** argv) { | 17 int main(int argc, char** argv) { |
21 uint32_t perm; | 18 uint32_t perm; |
22 uint32_t perm_pp_gl = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK; | 19 uint32_t perm_pp_gl = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK; |
23 uint32_t perm_pp = TPM_NV_PER_PPWRITE; | 20 uint32_t perm_pp = TPM_NV_PER_PPWRITE; |
24 uint32_t result; | |
25 | 21 |
26 TlclLibInit(); | 22 TlclLibInit(); |
27 TlclStartup(); | 23 TPM_CHECK(TlclStartupIfNeeded()); |
28 TlclContinueSelfTest(); | 24 TPM_CHECK(TlclContinueSelfTest()); |
29 TlclAssertPhysicalPresence(); | 25 TPM_CHECK(TlclAssertPhysicalPresence()); |
30 | 26 |
31 result = TlclGetPermissions(INDEX0, &perm); | 27 TPM_CHECK(TlclGetPermissions(INDEX0, &perm)); |
32 assert(result == TPM_SUCCESS); | |
33 printf("permissions for INDEX0 = 0x%x\n", perm); | |
34 assert((perm & perm_pp_gl) == perm_pp_gl); | 28 assert((perm & perm_pp_gl) == perm_pp_gl); |
35 | 29 |
36 result = TlclGetPermissions(INDEX1, &perm); | 30 TPM_CHECK(TlclGetPermissions(INDEX1, &perm)); |
37 assert(result == TPM_SUCCESS); | |
38 printf("permissions for INDEX1 = 0x%x\n", perm); | |
39 assert((perm & perm_pp) == perm_pp); | 31 assert((perm & perm_pp) == perm_pp); |
40 | 32 |
41 printf("Test completed successfully\n"); | 33 printf("TEST SUCCEEDED\n"); |
42 exit(0); | 34 exit(0); |
43 } | 35 } |
OLD | NEW |