blob: 824492741f8bc5503ee9731c486a541a3de33c14 [file] [log] [blame]
Vadim Bendeburyfea3a142015-05-28 18:53:22 -07001/*
2 * Copyright 2015 The Chromium OS Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7#ifndef __TPM2_CPRIHASH_FP_H
8#define __TPM2_CPRIHASH_FP_H
9
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070010LIB_EXPORT UINT16
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070011_cpri__CompleteHash(CPRI_HASH_STATE *hashState, // IN: the state of hash stack
12 UINT32 dOutSize, // IN: size of digest buffer
13 BYTE *dOut // OUT: hash digest
14 );
15LIB_EXPORT UINT16
16_cpri__CopyHashState(CPRI_HASH_STATE *out, // OUT: destination of the state
17 CPRI_HASH_STATE *in // IN: source of the state
18 );
19LIB_EXPORT UINT16
20_cpri__HashBlock(TPM_ALG_ID hashAlg, // IN: The hash algorithm
21 UINT32 dataSize, // IN: size of buffer to hash
22 BYTE *data, // IN: the buffer to hash
23 UINT32 digestSize, // IN: size of the digest buffer
24 BYTE *digest // OUT: hash digest
25 );
26LIB_EXPORT BOOL _cpri__HashStartup(void);
27LIB_EXPORT UINT16
28_cpri__GetDigestSize(TPM_ALG_ID hashAlg // IN: hash algorithm to look up
29 );
30LIB_EXPORT UINT16
31_cpri__GetHashDER(TPM_ALG_ID hashAlg, // IN: the algorithm to look up
32 const BYTE **p);
33LIB_EXPORT UINT16
34_cpri__KDFa(TPM_ALG_ID hashAlg, // IN: hash algorithm used in HMAC
35 TPM2B *key, // IN: HMAC key
36 const char *label, // IN: a 0-byte terminated label used in KDF
37 TPM2B *contextU, // IN: context U
38 TPM2B *contextV, // IN: context V
39 UINT32 sizeInBits, // IN: size of generated key in bit
40 BYTE *keyStream, // OUT: key buffer
41 UINT32 *counterInOut, // IN/OUT: caller may provide the iteration
42 // counter for incremental operations to
43 // avoid large intermediate buffers.
44 BOOL once // IN: TRUE if only one iteration is performed FALSE if
45 // iteration count determined by "sizeInBits"
46 );
47LIB_EXPORT UINT16
48_cpri__KDFe(TPM_ALG_ID hashAlg, // IN: hash algorithm used in HMAC
49 TPM2B *Z, // IN: Z
50 const char *label, // IN: a 0 terminated label using in KDF
51 TPM2B *partyUInfo, // IN: PartyUInfo
52 TPM2B *partyVInfo, // IN: PartyVInfo
53 UINT32 sizeInBits, // IN: size of generated key in bit
54 BYTE *keyStream // OUT: key buffer
55 );
56LIB_EXPORT CRYPT_RESULT
57_cpri__MGF1(UINT32 mSize, // IN: length of the mask to be produced
58 BYTE *mask, // OUT: buffer to receive the mask
59 TPM_ALG_ID hashAlg, // IN: hash to use
60 UINT32 sSize, // IN: size of the seed
61 BYTE *seed // IN: seed size
62 );
63LIB_EXPORT UINT16
64_cpri__StartHMAC(TPM_ALG_ID hashAlg, // IN: the algorithm to use
65 BOOL sequence, // IN: indicates if the state should be saved
66 CPRI_HASH_STATE *state, // IN/OUT: the state buffer
67 UINT16 keySize, // IN: the size of the HMAC key
68 BYTE *key, // IN: the HMAC key
69 TPM2B *oPadKey // OUT: the key prepared for the oPad round
70 );
71LIB_EXPORT UINT16
72_cpri__StartHash(TPM_ALG_ID hashAlg, // IN: hash algorithm
73 BOOL sequence, // IN: TRUE if the state should be saved
74 CPRI_HASH_STATE *hashState // OUT: the state of hash stack.
75 );
Vadim Bendebury0a050712015-05-29 11:35:04 -070076LIB_EXPORT void _cpri__UpdateHash(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070077 CPRI_HASH_STATE *hashState, // IN: the hash context information
78 UINT32 dataSize, // IN: the size of data to be added to the digest
79 BYTE *data // IN: data to be hashed
80 );
Vadim Bendeburyfea3a142015-05-28 18:53:22 -070081
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070082#endif // __TPM2_CPRIHASH_FP_H
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070083LIB_EXPORT UINT16 _cpri__CompleteHMAC(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070084 CPRI_HASH_STATE *hashState, // IN: the state of hash stack
85 TPM2B *oPadKey, // IN: the HMAC key in oPad format
86 UINT32 dOutSize, // IN: size of digest buffer
87 BYTE *dOut // OUT: hash digest
88 );
89LIB_EXPORT TPM_ALG_ID
90_cpri__GetContextAlg(CPRI_HASH_STATE *hashState // IN: the hash context
91 );
92LIB_EXPORT TPM_ALG_ID _cpri__GetHashAlgByIndex(UINT32 index // IN: the index
93 );
94LIB_EXPORT UINT16
95_cpri__GetHashBlockSize(TPM_ALG_ID hashAlg // IN: hash algorithm to look up
96 );
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070097LIB_EXPORT void _cpri__ImportExportHashState(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070098 CPRI_HASH_STATE *
99 osslFmt, // IN/OUT: the hash state formated for use by openSSL
100 EXPORT_HASH_STATE *externalFmt, // IN/OUT: the exported hash state
101 IMPORT_EXPORT direction //
102 );