summaryrefslogtreecommitdiff
path: root/src/tcs/tcsi_context.c
blob: d6fe606c890f0c3f85b1416403e167123eb583f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

/*
 * Licensed Materials - Property of IBM
 *
 * trousers - An open source TCG Software Stack
 *
 * (C) Copyright International Business Machines Corp. 2004
 *
 */


#include <stdlib.h>
#include <stdio.h>

#include "trousers/tss.h"
#include "trousers_types.h"
#include "tcs_tsp.h"
#include "tcs_utils.h"
#include "tcs_int_literals.h"
#include "capabilities.h"
#include "tcslog.h"


TSS_RESULT
TCS_OpenContext_Internal(TCS_CONTEXT_HANDLE * hContext)	/* out  */
{
	*hContext = make_context();
	if (*hContext == 0)
		return TCSERR(TSS_E_OUTOFMEMORY);

	return TSS_SUCCESS;
}

TSS_RESULT
TCS_CloseContext_Internal(TCS_CONTEXT_HANDLE hContext)	/* in */
{
	TSS_RESULT result;

	LogDebug("Closing context %.8X", hContext);

	if ((result = ctx_verify_context(hContext)))
		return result;

	destroy_context(hContext);

	/* close all auth handles associated with hContext */
	auth_mgr_close_context(hContext);

	KEY_MGR_ref_count();

	LogDebug("Context %.8X closed", hContext);
	return TSS_SUCCESS;
}

TSS_RESULT
TCS_FreeMemory_Internal(TCS_CONTEXT_HANDLE hContext,	/* in */
			BYTE *pMemory)			/* in */
{
	free(pMemory);

	return TSS_SUCCESS;
}