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