tpmadm.h revision 11070:3ac202191cfa
114596Snate/*
214596Snate * CDDL HEADER START
350472Speter *
438738Sbrian * The contents of this file are subject to the terms of the
5150882Sbrooks * Common Development and Distribution License (the "License").
614596Snate * You may not use this file except in compliance with the License.
7147088Sbrooks *
814596Snate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
914596Snate * or http://www.opensolaris.org/os/licensing.
10147088Sbrooks * See the License for the specific language governing permissions
11118840Smbr * and limitations under the License.
12118840Smbr *
13150882Sbrooks * When distributing Covered Code, include this CDDL HEADER in each
14150882Sbrooks * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15150882Sbrooks * If applicable, add the following below this CDDL HEADER, with the
16150882Sbrooks * fields enclosed by brackets "[]" replaced with your own identifying
17150882Sbrooks * information: Portions Copyright [yyyy] [name of copyright owner]
18150882Sbrooks *
19150882Sbrooks * CDDL HEADER END
20287394Sglebius */
21287394Sglebius
22287394Sglebius/*
23118840Smbr * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24147088Sbrooks * Use is subject to license terms.
25147088Sbrooks */
26147088Sbrooks
27147088Sbrooks#ifndef _TPMADM_H
28147088Sbrooks#define	_TPMADM_H
29118840Smbr
30118840Smbr#define	ERR_FAIL 1
31147088Sbrooks#define	ERR_USAGE 2
32147088Sbrooks
33118840Smbrtypedef int (*cmdfunc_t)(TSS_HCONTEXT hContext, TSS_HTPM hTPM,
34118840Smbr    int argc, char *argv[]);
3567221Sjoe
36147088Sbrookstypedef struct {
37147088Sbrooks	char *name;
38147088Sbrooks	char *args;
39147088Sbrooks	cmdfunc_t func;
4067221Sjoe} cmdtable_t;
41147088Sbrooks
42147088Sbrooks/* Utility functions */
43147088Sbrooksvoid print_bytes(BYTE *bytes, size_t len, int formatted);
44147088Sbrooksvoid print_error(TSS_RESULT ret, char *msg);
45147088Sbrooksint get_tpm_capability(TSS_HCONTEXT hContext, TSS_HOBJECT hTPM,
46147088Sbrooks    UINT32 cap, UINT32 subcap, void *buf, size_t bufsize);
47147088Sbrooksint set_policy_options(TSS_HPOLICY hPolicy, TSS_FLAG mode, char *prompt,
48147088Sbrooks    UINT32 secret_len, BYTE *secret);
4967221Sjoeint set_object_policy(TSS_HOBJECT handle, TSS_FLAG mode, char *prompt,
5067221Sjoe    UINT32 secret_len, BYTE *secret);
51147088Sbrooksint tpm_preamble(TSS_HCONTEXT *hContext, TSS_HOBJECT *hTPM);
52147088Sbrooksint tpm_postamble(TSS_HCONTEXT hContext);
53147088Sbrooks
54147088Sbrooks#define	UUID_PARSE(str, uuid)	uuid_parse(str, *(uuid_t *)&uuid)
55147088Sbrooks#define	UUID_UNPARSE(uuid, str)	uuid_unparse(*(uuid_t *)&uuid, str)
56147088Sbrooks#define	UUID_COPY(source, dest)  \
57147088Sbrooks	bcopy((BYTE*)&(source), (BYTE*)&(dest), sizeof (TSS_UUID))
58147088Sbrooks#endif /* _TPMADM_H */
59147088Sbrooks