blob: 06047a9984cc1feb85f76b1a044ea3153446df53 [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 Bendebury0a050712015-05-29 11:35:04 -070010LIB_EXPORT UINT16 _cpri__CompleteHash(
11 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);
Vadim Bendebury42c3ea12015-05-29 22:46:51 -070015LIB_EXPORT UINT16 _cpri__CopyHashState (
16 CPRI_HASH_STATE *out, // OUT: destination of the state
17 CPRI_HASH_STATE *in // IN: source of the state
18);
19LIB_EXPORT UINT16 _cpri__HashBlock(
20 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);
Vadim Bendeburyfea3a142015-05-28 18:53:22 -070026LIB_EXPORT BOOL _cpri__HashStartup(void);
Vadim Bendebury0a050712015-05-29 11:35:04 -070027LIB_EXPORT UINT16 _cpri__GetDigestSize(
28 TPM_ALG_ID hashAlg // IN: hash algorithm to look up
29);
Vadim Bendebury42c3ea12015-05-29 22:46:51 -070030LIB_EXPORT UINT16 _cpri__GetHashDER(
31 TPM_ALG_ID hashAlg, // IN: the algorithm to look up
32 const BYTE **p
33);
Vadim Bendebury0a050712015-05-29 11:35:04 -070034LIB_EXPORT UINT16 _cpri__KDFa(
35 TPM_ALG_ID hashAlg, // IN: hash algorithm used in HMAC
36 TPM2B *key, // IN: HMAC key
37 const char *label, // IN: a 0-byte terminated label used in KDF
38 TPM2B *contextU, // IN: context U
39 TPM2B *contextV, // IN: context V
40 UINT32 sizeInBits, // IN: size of generated key in bit
41 BYTE *keyStream, // OUT: key buffer
42 UINT32 *counterInOut, // IN/OUT: caller may provide the iteration
43 // counter for incremental operations to
44 // avoid large intermediate buffers.
45 BOOL once // IN: TRUE if only one iteration is performed
46 // FALSE if iteration count determined by
47 // "sizeInBits"
48);
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070049LIB_EXPORT UINT16
50_cpri__KDFe(
51 TPM_ALG_ID hashAlg, // IN: hash algorithm used in HMAC
52 TPM2B *Z, // IN: Z
53 const char *label, // IN: a 0 terminated label using in KDF
54 TPM2B *partyUInfo, // IN: PartyUInfo
55 TPM2B *partyVInfo, // IN: PartyVInfo
56 UINT32 sizeInBits, // IN: size of generated key in bit
57 BYTE *keyStream // OUT: key buffer
58);
Vadim Bendebury42c3ea12015-05-29 22:46:51 -070059LIB_EXPORT CRYPT_RESULT _cpri__MGF1(
60 UINT32 mSize, // IN: length of the mask to be produced
61 BYTE *mask, // OUT: buffer to receive the mask
62 TPM_ALG_ID hashAlg, // IN: hash to use
63 UINT32 sSize, // IN: size of the seed
64 BYTE *seed // IN: seed size
65);
66LIB_EXPORT UINT16 _cpri__StartHMAC(
67 TPM_ALG_ID hashAlg, // IN: the algorithm to use
68 BOOL sequence, // IN: indicates if the state should be
69 // saved
70 CPRI_HASH_STATE *state, // IN/OUT: the state buffer
71 UINT16 keySize, // IN: the size of the HMAC key
72 BYTE *key, // IN: the HMAC key
73 TPM2B *oPadKey // OUT: the key prepared for the oPad round
74);
Vadim Bendebury0a050712015-05-29 11:35:04 -070075LIB_EXPORT UINT16 _cpri__StartHash(
76 TPM_ALG_ID hashAlg, // IN: hash algorithm
77 BOOL sequence, // IN: TRUE if the state should be saved
78 CPRI_HASH_STATE *hashState // OUT: the state of hash stack.
79);
80LIB_EXPORT void _cpri__UpdateHash(
81 CPRI_HASH_STATE *hashState, // IN: the hash context information
82 UINT32 dataSize, // IN: the size of data to be added to the
83 // digest
84 BYTE *data // IN: data to be hashed
85);
Vadim Bendeburyfea3a142015-05-28 18:53:22 -070086
87#endif // __TPM2_CPRIHASH_FP_H
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070088LIB_EXPORT UINT16 _cpri__CompleteHMAC(
89 CPRI_HASH_STATE *hashState, // IN: the state of hash stack
90 TPM2B *oPadKey, // IN: the HMAC key in oPad format
91 UINT32 dOutSize, // IN: size of digest buffer
92 BYTE *dOut // OUT: hash digest
93 );
94LIB_EXPORT TPM_ALG_ID _cpri__GetContextAlg(
95 CPRI_HASH_STATE *hashState // IN: the hash context
96 );
97LIB_EXPORT TPM_ALG_ID _cpri__GetHashAlgByIndex(
98 UINT32 index // IN: the index
99 );
100LIB_EXPORT UINT16 _cpri__GetHashBlockSize(
101 TPM_ALG_ID hashAlg // IN: hash algorithm to look up
102 );
103LIB_EXPORT void _cpri__ImportExportHashState(
104 CPRI_HASH_STATE *osslFmt, // IN/OUT: the hash state formated for use
105 // by openSSL
106 EXPORT_HASH_STATE *externalFmt, // IN/OUT: the exported hash state
107 IMPORT_EXPORT direction //
108 );