xref: /netbsd-src/crypto/external/cpl/trousers/dist/src/include/obj_nv.h (revision a4ddc2c8fb9af816efe3b1c375a5530aef0e89e9)
1 /*
2  * The Initial Developer of the Original Code is Intel Corporation.
3  * Portions created by Intel Corporation are Copyright (C) 2007 Intel Corporation.
4  * All Rights Reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the Common Public License as published by
8  * IBM Corporation; either version 1 of the License, or (at your option)
9  * any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * Common Public License for more details.
15  *
16  * You should have received a copy of the Common Public License
17  * along with this program; if not, a copy can be viewed at
18  * http://www.opensource.org/licenses/cpl1.0.php.
19  *
20  * trousers - An open source TCG Software Stack
21  *
22  * Author: james.xu@intel.com Rossey.liu@intel.com
23  *
24  */
25 
26 #ifndef _OBJ_NVSTORE_H_
27 #define _OBJ_NVSTORE_H_
28 
29 #ifdef TSS_BUILD_NV
30 
31 #define MAX_PUBLIC_DATA_SIZE 1024
32 #define TSS_LOCALITY_MASK 0x1f
33 
34 typedef struct objNV_DATA_PUBLIC
35 {
36 	TPM_STRUCTURE_TAG tag;
37 	TPM_NV_INDEX nvIndex;
38 	TPM_NV_ATTRIBUTES permission;
39 	TPM_BOOL bReadSTClear;
40 	TPM_BOOL bWriteSTClear;
41 	TPM_BOOL bWriteDefine;
42 	UINT32 dataSize;
43 }NV_DATA_PUBLIC;
44 
45 /* structures */
46 struct tr_nvstore_obj {
47 	TPM_STRUCTURE_TAG tag;
48 	TPM_NV_INDEX nvIndex;
49 	TPM_NV_ATTRIBUTES permission;
50 	TPM_BOOL bReadSTClear;
51 	TPM_BOOL bWriteSTClear;
52 	TPM_BOOL bWriteDefine;
53 	UINT32 dataSize;
54 	TSS_HPOLICY policy;
55 };
56 
57 /* obj_nv.c */
58 void       nvstore_free(void *data);
59 TSS_RESULT obj_nvstore_add(TSS_HCONTEXT, TSS_HOBJECT *);
60 TSS_BOOL   obj_is_nvstore(TSS_HOBJECT tspContext);
61 TSS_RESULT obj_nvstore_remove(TSS_HOBJECT, TSS_HCONTEXT);
62 TSS_RESULT obj_nvstore_get_tsp_context(TSS_HNVSTORE, TSS_HCONTEXT *);
63 TSS_RESULT obj_nvstore_set_index(TSS_HNVSTORE, UINT32);
64 TSS_RESULT obj_nvstore_get_index(TSS_HNVSTORE, UINT32 *);
65 TSS_RESULT obj_nvstore_set_datasize(TSS_HNVSTORE, UINT32);
66 TSS_RESULT obj_nvstore_get_datasize(TSS_HNVSTORE, UINT32 *);
67 TSS_RESULT obj_nvstore_set_permission(TSS_HNVSTORE, UINT32);
68 TSS_RESULT obj_nvstore_get_permission_from_tpm(TSS_HNVSTORE hNvstore, UINT32 * permission);
69 TSS_RESULT obj_nvstore_get_permission(TSS_HNVSTORE, UINT32 *);
70 TSS_RESULT obj_nvstore_set_policy(TSS_HNVSTORE, TSS_HPOLICY);
71 TSS_RESULT obj_nvstore_get_policy(TSS_HNVSTORE, UINT32, TSS_HPOLICY *);
72 TSS_RESULT obj_nvstore_get_datapublic(TSS_HNVSTORE, UINT32 *, BYTE *);
73 TSS_RESULT obj_nvstore_get_readdigestatrelease(TSS_HNVSTORE, UINT32 *, BYTE **);
74 TSS_RESULT obj_nvstore_get_readpcrselection(TSS_HNVSTORE, UINT32 *, BYTE **);
75 TSS_RESULT obj_nvstore_get_writedigestatrelease(TSS_HNVSTORE, UINT32 *, BYTE **);
76 TSS_RESULT obj_nvstore_get_writepcrselection(TSS_HNVSTORE, UINT32 *, BYTE **);
77 TSS_RESULT obj_nvstore_get_state_readstclear(TSS_HNVSTORE, UINT32 *);
78 TSS_RESULT obj_nvstore_get_state_writedefine(TSS_HNVSTORE, UINT32 *);
79 TSS_RESULT obj_nvstore_get_state_writestclear(TSS_HNVSTORE, UINT32 *);
80 TSS_RESULT obj_nvstore_get_readlocalityatrelease(TSS_HNVSTORE, UINT32 *);
81 TSS_RESULT obj_nvstore_get_writelocalityatrelease(TSS_HNVSTORE, UINT32 *);
82 TSS_RESULT obj_nvstore_create_pcrshortinfo(TSS_HNVSTORE, TSS_HPCRS, UINT32 *, BYTE **);
83 
84 #define NVSTORE_LIST_DECLARE		struct obj_list nvstore_list
85 #define NVSTORE_LIST_DECLARE_EXTERN	extern struct obj_list nvstore_list
86 #define NVSTORE_LIST_INIT()		list_init(&nvstore_list)
87 #define NVSTORE_LIST_CONNECT(a,b)	obj_connectContext_list(&nvstore_list, a, b)
88 #define NVSTORE_LIST_CLOSE(a)		obj_list_close(&nvstore_list, &nvstore_free, a)
89 #else
90 #define NVSTORE_LIST_DECLARE
91 #define NVSTORE_LIST_DECLARE_EXTERN
92 #define NVSTORE_LIST_INIT()
93 #define NVSTORE_LIST_CONNECT(a,b)
94 #define NVSTORE_LIST_CLOSE(a)
95 #endif
96 #endif
97 
98