xref: /aosp_15_r20/external/vboot_reference/tests/tpm_lite/tpmtest_spaceperm.c (revision 8617a60d3594060b7ecbd21bc622a7c14f3cf2bc)
1 /* Copyright 2011 The ChromiumOS Authors
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 /* Test of space permissions retrieval.
7  */
8 
9 #include <stdint.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 
13 #include "host_common.h"
14 #include "common/tests.h"
15 #include "tlcl.h"
16 #include "tlcl_tests.h"
17 
18 #define PERMPPGL (TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK)
19 #define PERMPP TPM_NV_PER_PPWRITE
20 
main(int argc,char ** argv)21 int main(int argc, char** argv) {
22 	uint32_t perm;
23 
24 	TlclLibInit();
25 	TPM_CHECK(TlclStartupIfNeeded());
26 	TPM_CHECK(TlclContinueSelfTest());
27 	TPM_CHECK(TlclAssertPhysicalPresence());
28 
29 	TPM_CHECK(TlclGetPermissions(INDEX0, &perm));
30 	TEST_NEQ(perm & PERMPPGL, 0, "INDEX0: PERMPPGL is not set");
31 
32 	TPM_CHECK(TlclGetPermissions(INDEX1, &perm));
33 	TEST_NEQ(perm & PERMPP, 0, "INDEX1: PERMPP is not set");
34 
35 	printf("TEST SUCCEEDED\n");
36 	exit(0);
37 }
38