xref: /illumos-gate/usr/src/lib/pkcs11/pkcs11_tpm/common/tpmtok_defs.h (revision 47e946e784719ae402ace34695f67b0e6e76ae5c)
1*47e946e7SWyllys Ingersoll /*
2*47e946e7SWyllys Ingersoll  * The Initial Developer of the Original Code is International
3*47e946e7SWyllys Ingersoll  * Business Machines Corporation. Portions created by IBM
4*47e946e7SWyllys Ingersoll  * Corporation are Copyright (C) 2005 International Business
5*47e946e7SWyllys Ingersoll  * Machines Corporation. All Rights Reserved.
6*47e946e7SWyllys Ingersoll  *
7*47e946e7SWyllys Ingersoll  * This program is free software; you can redistribute it and/or modify
8*47e946e7SWyllys Ingersoll  * it under the terms of the Common Public License as published by
9*47e946e7SWyllys Ingersoll  * IBM Corporation; either version 1 of the License, or (at your option)
10*47e946e7SWyllys Ingersoll  * any later version.
11*47e946e7SWyllys Ingersoll  *
12*47e946e7SWyllys Ingersoll  * This program is distributed in the hope that it will be useful,
13*47e946e7SWyllys Ingersoll  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14*47e946e7SWyllys Ingersoll  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*47e946e7SWyllys Ingersoll  * Common Public License for more details.
16*47e946e7SWyllys Ingersoll  *
17*47e946e7SWyllys Ingersoll  * You should have received a copy of the Common Public License
18*47e946e7SWyllys Ingersoll  * along with this program; if not, a copy can be viewed at
19*47e946e7SWyllys Ingersoll  * http://www.opensource.org/licenses/cpl1.0.php.
20*47e946e7SWyllys Ingersoll  */
21*47e946e7SWyllys Ingersoll /*
22*47e946e7SWyllys Ingersoll  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23*47e946e7SWyllys Ingersoll  * Use is subject to license terms.
24*47e946e7SWyllys Ingersoll  */
25*47e946e7SWyllys Ingersoll 
26*47e946e7SWyllys Ingersoll #ifndef _TPMTOK_DEFS_H
27*47e946e7SWyllys Ingersoll #define	_TPMTOK_DEFS_H
28*47e946e7SWyllys Ingersoll 
29*47e946e7SWyllys Ingersoll /* TSS key type helper */
30*47e946e7SWyllys Ingersoll #define	TPMTOK_TSS_KEY_TYPE_MASK	0x000000F0
31*47e946e7SWyllys Ingersoll #define	TPMTOK_TSS_KEY_TYPE(x)		(x & TPMTOK_TSS_KEY_TYPE_MASK)
32*47e946e7SWyllys Ingersoll #define	TPMTOK_TSS_KEY_MIG_TYPE(x)	(x & TSS_KEY_MIGRATABLE)
33*47e946e7SWyllys Ingersoll 
34*47e946e7SWyllys Ingersoll #define	TPMTOK_TSS_MAX_ERROR		0x00000FFF
35*47e946e7SWyllys Ingersoll #define	TPMTOK_TSS_ERROR_CODE(x)	(x & TPMTOK_TSS_MAX_ERROR)
36*47e946e7SWyllys Ingersoll 
37*47e946e7SWyllys Ingersoll /* key types in the TPM token */
38*47e946e7SWyllys Ingersoll #define	TPMTOK_PRIVATE_ROOT_KEY	1
39*47e946e7SWyllys Ingersoll #define	TPMTOK_PRIVATE_LEAF_KEY	2
40*47e946e7SWyllys Ingersoll #define	TPMTOK_PUBLIC_ROOT_KEY	3
41*47e946e7SWyllys Ingersoll #define	TPMTOK_PUBLIC_LEAF_KEY	4
42*47e946e7SWyllys Ingersoll 
43*47e946e7SWyllys Ingersoll /* key identifiers for the PKCS#11 objects */
44*47e946e7SWyllys Ingersoll #define	TPMTOK_PRIVATE_ROOT_KEY_ID	"PRIVATE_ROOT_KEY"
45*47e946e7SWyllys Ingersoll #define	TPMTOK_PRIVATE_LEAF_KEY_ID	"PRIVATE_LEAF_KEY"
46*47e946e7SWyllys Ingersoll #define	TPMTOK_PUBLIC_ROOT_KEY_ID	"PUBLIC_ROOT_KEY"
47*47e946e7SWyllys Ingersoll #define	TPMTOK_PUBLIC_LEAF_KEY_ID	"PUBLIC_LEAF_KEY"
48*47e946e7SWyllys Ingersoll 
49*47e946e7SWyllys Ingersoll #define	NULL_HKEY	0
50*47e946e7SWyllys Ingersoll #define	NULL_HENCDATA	0
51*47e946e7SWyllys Ingersoll #define	NULL_HPOLICY	0
52*47e946e7SWyllys Ingersoll #define	NULL_HCONTEXT	0
53*47e946e7SWyllys Ingersoll #define	NULL_HPCRS	0
54*47e946e7SWyllys Ingersoll 
55*47e946e7SWyllys Ingersoll #define	LOG(priority, fmt, ...) \
56*47e946e7SWyllys Ingersoll {\
57*47e946e7SWyllys Ingersoll 	openlog("tpmtoken", LOG_NDELAY|LOG_PID, LOG_USER);\
58*47e946e7SWyllys Ingersoll 	syslog(priority, "%s " fmt, __FILE__, ##__VA_ARGS__);\
59*47e946e7SWyllys Ingersoll }
60*47e946e7SWyllys Ingersoll 
61*47e946e7SWyllys Ingersoll #endif /* _TPMTOK_DEFS_H */
62