xref: /netbsd-src/crypto/external/cpl/trousers/dist/src/tcs/tcsi_context.c (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 
12 #include <stdlib.h>
13 #include <stdio.h>
14 
15 #include "trousers/tss.h"
16 #include "trousers_types.h"
17 #include "tcs_tsp.h"
18 #include "tcs_utils.h"
19 #include "tcs_int_literals.h"
20 #include "capabilities.h"
21 #include "tcslog.h"
22 
23 
24 TSS_RESULT
TCS_OpenContext_Internal(TCS_CONTEXT_HANDLE * hContext)25 TCS_OpenContext_Internal(TCS_CONTEXT_HANDLE * hContext)	/* out  */
26 {
27 	*hContext = make_context();
28 	if (*hContext == 0)
29 		return TCSERR(TSS_E_OUTOFMEMORY);
30 
31 	return TSS_SUCCESS;
32 }
33 
34 TSS_RESULT
TCS_CloseContext_Internal(TCS_CONTEXT_HANDLE hContext)35 TCS_CloseContext_Internal(TCS_CONTEXT_HANDLE hContext)	/* in */
36 {
37 	TSS_RESULT result;
38 
39 	LogDebug("Closing context %.8X", hContext);
40 
41 	if ((result = ctx_verify_context(hContext)))
42 		return result;
43 
44 	destroy_context(hContext);
45 
46 	/* close all auth handles associated with hContext */
47 	auth_mgr_close_context(hContext);
48 
49 	KEY_MGR_ref_count();
50 
51 	LogDebug("Context %.8X closed", hContext);
52 	return TSS_SUCCESS;
53 }
54 
55 TSS_RESULT
TCS_FreeMemory_Internal(TCS_CONTEXT_HANDLE hContext,BYTE * pMemory)56 TCS_FreeMemory_Internal(TCS_CONTEXT_HANDLE hContext,	/* in */
57 			BYTE *pMemory)			/* in */
58 {
59 	free(pMemory);
60 
61 	return TSS_SUCCESS;
62 }
63