summaryrefslogtreecommitdiff
path: root/src/tspi/tspi_hash.c
blob: dfd3fcbb81501faf767580b11026e66a0ac86183 (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

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


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

#include "trousers/tss.h"
#include "trousers/trousers.h"
#include "trousers_types.h"
#include "spi_utils.h"
#include "capabilities.h"
#include "tsplog.h"
#include "obj.h"


TSS_RESULT
Tspi_Hash_SetHashValue(TSS_HHASH hHash,			/* in */
		       UINT32 ulHashValueLength,	/* in */
		       BYTE * rgbHashValue)		/* in */
{
	if (ulHashValueLength == 0 || rgbHashValue == NULL)
		return TSPERR(TSS_E_BAD_PARAMETER);

	return obj_hash_set_value(hHash, ulHashValueLength, rgbHashValue);
}

TSS_RESULT
Tspi_Hash_GetHashValue(TSS_HHASH hHash,			/* in */
		       UINT32 * pulHashValueLength,	/* out */
		       BYTE ** prgbHashValue)		/* out */
{
	if (pulHashValueLength == NULL || prgbHashValue == NULL)
		return TSPERR(TSS_E_BAD_PARAMETER);

	return obj_hash_get_value(hHash, pulHashValueLength, prgbHashValue);
}

TSS_RESULT
Tspi_Hash_UpdateHashValue(TSS_HHASH hHash,	/* in */
			  UINT32 ulDataLength,	/* in */
			  BYTE *rgbData)	/* in */
{
	if (rgbData == NULL && ulDataLength != 0)
		return TSPERR(TSS_E_BAD_PARAMETER);

	if (ulDataLength == 0)
		return TSS_SUCCESS;

	return obj_hash_update_value(hHash, ulDataLength, rgbData);
}