xref: /titanic_50/usr/src/cmd/cmd-crypto/tpmadm/tpmadm.h (revision 81d9f076db88c1f40c85831ce1ebb444a209c5a8)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _TPMADM_H
28 #define	_TPMADM_H
29 
30 #define	ERR_FAIL 1
31 #define	ERR_USAGE 2
32 
33 typedef int (*cmdfunc_t)(TSS_HCONTEXT hContext, TSS_HTPM hTPM,
34     int argc, char *argv[]);
35 
36 typedef struct {
37 	char *name;
38 	char *args;
39 	cmdfunc_t func;
40 } cmdtable_t;
41 
42 /* Utility functions */
43 void print_bytes(BYTE *bytes, size_t len, int formatted);
44 void print_error(TSS_RESULT ret, char *msg);
45 int get_tpm_capability(TSS_HCONTEXT hContext, TSS_HOBJECT hTPM,
46     UINT32 cap, UINT32 subcap, void *buf, size_t bufsize);
47 int set_policy_options(TSS_HPOLICY hPolicy, TSS_FLAG mode, char *prompt,
48     UINT32 secret_len, BYTE *secret);
49 int set_object_policy(TSS_HOBJECT handle, TSS_FLAG mode, char *prompt,
50     UINT32 secret_len, BYTE *secret);
51 int tpm_preamble(TSS_HCONTEXT *hContext, TSS_HOBJECT *hTPM);
52 int tpm_postamble(TSS_HCONTEXT hContext);
53 
54 #define	UUID_PARSE(str, uuid)	uuid_parse(str, *(uuid_t *)&uuid)
55 #define	UUID_UNPARSE(uuid, str)	uuid_unparse(*(uuid_t *)&uuid, str)
56 #define	UUID_COPY(source, dest)  \
57 	bcopy((BYTE*)&(source), (BYTE*)&(dest), sizeof (TSS_UUID))
58 #endif /* _TPMADM_H */
59