xref: /netbsd-src/crypto/external/cpl/trousers/dist/src/include/auth_mgr.h (revision 2d5f7628c5531eb583b9313ac2fd1cf8582b4479)
1 
2 /*
3  * Licensed Materials - Property of IBM
4  *
5  * trousers - An open source TCG Software Stack
6  *
7  * (C) Copyright International Business Machines Corp. 2004
8  *
9  */
10 
11 #ifndef _AUTH_MGR_H_
12 #define _AUTH_MGR_H_
13 
14 struct auth_map
15 {
16 	TSS_BOOL full;
17 	TPM_AUTHHANDLE tpm_handle;
18 	TCS_CONTEXT_HANDLE tcs_ctx;
19 	BYTE *swap; /* These 'swap' variables manage blobs received from TPM_SaveAuthContext */
20 	UINT32 swap_size;
21 };
22 
23 /*
24  * it appears that there's no way to query a v1.1 TPM for the
25  * max number of simultaneous auth sessions. We'll make the
26  * default relatively large and let the TPM return
27  * TCPA_RESOURCES to tell us when we cross the line.
28  */
29 #define TSS_DEFAULT_AUTH_TABLE_SIZE	16
30 #define TSS_DEFAULT_OVERFLOW_AUTHS	16
31 
32 struct _auth_mgr
33 {
34 	short max_auth_sessions;
35 	short open_auth_sessions;
36 	UINT32 sleeping_threads;
37 	COND_VAR **overflow;	/* queue of TCS contexts waiting for an auth session to become
38 				 * available */
39 	unsigned int of_head, of_tail;	/* head and tail of the overflow queue */
40 	struct auth_map *auth_mapper; /* table of currently tracked auth sessions */
41 	UINT32 auth_mapper_size, overflow_size;
42 } auth_mgr;
43 
44 MUTEX_DECLARE_INIT(auth_mgr_lock);
45 
46 TSS_RESULT TPM_SaveAuthContext(TPM_AUTHHANDLE, UINT32 *, BYTE **);
47 TSS_RESULT TPM_LoadAuthContext(UINT32, BYTE *, TPM_AUTHHANDLE *);
48 
49 #endif
50