xref: /titanic_51/usr/src/cmd/cmd-crypto/tpmadm/tpmadm.h (revision 304d8f901e34de2a80ef006bfa8a8a927d23d56c)
147e946e7SWyllys Ingersoll /*
247e946e7SWyllys Ingersoll  * CDDL HEADER START
347e946e7SWyllys Ingersoll  *
447e946e7SWyllys Ingersoll  * The contents of this file are subject to the terms of the
547e946e7SWyllys Ingersoll  * Common Development and Distribution License (the "License").
647e946e7SWyllys Ingersoll  * You may not use this file except in compliance with the License.
747e946e7SWyllys Ingersoll  *
847e946e7SWyllys Ingersoll  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
947e946e7SWyllys Ingersoll  * or http://www.opensolaris.org/os/licensing.
1047e946e7SWyllys Ingersoll  * See the License for the specific language governing permissions
1147e946e7SWyllys Ingersoll  * and limitations under the License.
1247e946e7SWyllys Ingersoll  *
1347e946e7SWyllys Ingersoll  * When distributing Covered Code, include this CDDL HEADER in each
1447e946e7SWyllys Ingersoll  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1547e946e7SWyllys Ingersoll  * If applicable, add the following below this CDDL HEADER, with the
1647e946e7SWyllys Ingersoll  * fields enclosed by brackets "[]" replaced with your own identifying
1747e946e7SWyllys Ingersoll  * information: Portions Copyright [yyyy] [name of copyright owner]
1847e946e7SWyllys Ingersoll  *
1947e946e7SWyllys Ingersoll  * CDDL HEADER END
2047e946e7SWyllys Ingersoll  */
2147e946e7SWyllys Ingersoll 
2247e946e7SWyllys Ingersoll /*
2347e946e7SWyllys Ingersoll  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
2447e946e7SWyllys Ingersoll  * Use is subject to license terms.
2547e946e7SWyllys Ingersoll  */
2647e946e7SWyllys Ingersoll 
2747e946e7SWyllys Ingersoll #ifndef _TPMADM_H
2847e946e7SWyllys Ingersoll #define	_TPMADM_H
2947e946e7SWyllys Ingersoll 
3047e946e7SWyllys Ingersoll #define	ERR_FAIL 1
3147e946e7SWyllys Ingersoll #define	ERR_USAGE 2
3247e946e7SWyllys Ingersoll 
3347e946e7SWyllys Ingersoll typedef int (*cmdfunc_t)(TSS_HCONTEXT hContext, TSS_HTPM hTPM,
3447e946e7SWyllys Ingersoll     int argc, char *argv[]);
3547e946e7SWyllys Ingersoll 
3647e946e7SWyllys Ingersoll typedef struct {
3747e946e7SWyllys Ingersoll 	char *name;
3847e946e7SWyllys Ingersoll 	char *args;
3947e946e7SWyllys Ingersoll 	cmdfunc_t func;
4047e946e7SWyllys Ingersoll } cmdtable_t;
4147e946e7SWyllys Ingersoll 
4247e946e7SWyllys Ingersoll /* Utility functions */
4347e946e7SWyllys Ingersoll void print_bytes(BYTE *bytes, size_t len, int formatted);
4447e946e7SWyllys Ingersoll void print_error(TSS_RESULT ret, char *msg);
4547e946e7SWyllys Ingersoll int get_tpm_capability(TSS_HCONTEXT hContext, TSS_HOBJECT hTPM,
4647e946e7SWyllys Ingersoll     UINT32 cap, UINT32 subcap, void *buf, size_t bufsize);
47*304d8f90SScott Rotondo int set_policy_options(TSS_HPOLICY hPolicy, TSS_FLAG mode, char *prompt,
48*304d8f90SScott Rotondo     UINT32 secret_len, BYTE *secret);
49*304d8f90SScott Rotondo int set_object_policy(TSS_HOBJECT handle, TSS_FLAG mode, char *prompt,
50*304d8f90SScott Rotondo     UINT32 secret_len, BYTE *secret);
5147e946e7SWyllys Ingersoll int tpm_preamble(TSS_HCONTEXT *hContext, TSS_HOBJECT *hTPM);
5247e946e7SWyllys Ingersoll int tpm_postamble(TSS_HCONTEXT hContext);
5347e946e7SWyllys Ingersoll 
5447e946e7SWyllys Ingersoll #define	UUID_PARSE(str, uuid)	uuid_parse(str, *(uuid_t *)&uuid)
5547e946e7SWyllys Ingersoll #define	UUID_UNPARSE(uuid, str)	uuid_unparse(*(uuid_t *)&uuid, str)
5647e946e7SWyllys Ingersoll #define	UUID_COPY(source, dest)  \
5747e946e7SWyllys Ingersoll 	bcopy((BYTE*)&(source), (BYTE*)&(dest), sizeof (TSS_UUID))
5847e946e7SWyllys Ingersoll #endif /* _TPMADM_H */
59