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