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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
/* Copyright 2015 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#define TPM_FAIL_C
#include "Global.h"
#include "CryptoEngine.h"
CRYPT_RESULT _cpri__C_2_2_KeyExchange(
TPMS_ECC_POINT * outZ1, // OUT: a computed point
TPMS_ECC_POINT * outZ2, // OUT: and optional second point
TPM_ECC_CURVE curveId, // IN: the curve for the computations
TPM_ALG_ID scheme, // IN: the key exchange scheme
TPM2B_ECC_PARAMETER * dsA, // IN: static private TPM key
TPM2B_ECC_PARAMETER * deA, // IN: ephemeral private TPM key
TPMS_ECC_POINT * QsB, // IN: static public party B key
TPMS_ECC_POINT * QeB // IN: ephemeral public party B key
)
{
ecprintf("%s called\n", __func__);
return CRYPT_FAIL;
}
CRYPT_RESULT _cpri__DrbgGetPutState(
GET_PUT direction,
int bufferSize,
BYTE * buffer)
{
/* This unction is not implemented in the TPM2 library either. */
return CRYPT_SUCCESS;
}
CRYPT_RESULT _cpri__EccCommitCompute(
TPMS_ECC_POINT * K, // OUT: [d]B or [r]Q
TPMS_ECC_POINT * L, // OUT: [r]B
TPMS_ECC_POINT * E, // OUT: [r]M
TPM_ECC_CURVE curveId, // IN: the curve for the computations
TPMS_ECC_POINT * M, // IN: M (optional)
TPMS_ECC_POINT * B, // IN: B (optional)
TPM2B_ECC_PARAMETER * d, // IN: d (required)
TPM2B_ECC_PARAMETER * r // IN: the computed r value (required)
)
{
ecprintf("%s called\n", __func__);
return CRYPT_FAIL;
}
CRYPT_RESULT _cpri__GenerateKeyRSA(
TPM2B * n, // OUT: The public modulu
TPM2B * p, // OUT: One of the prime factors of n
UINT16 keySizeInBits, // IN: Size of the public modulus in bit
UINT32 e, // IN: The public exponent
TPM_ALG_ID hashAlg, // IN: hash algorithm to use in the key generation proce
TPM2B * seed, // IN: the seed to use
const char *label, // IN: A label for the generation process.
TPM2B * extra, // IN: Party 1 data for the KDF
UINT32 * counter // IN/OUT: Counter value to allow KFD iteration to be
// propagated across multiple routine
)
{
ecprintf("%s called\n", __func__);
return CRYPT_FAIL;
}
BOOL _cpri__Startup(
void)
{
/*
* Below is the list of functions called by the TPM2 library from
* _cpri__Startup().
* TODO(vbendeb): verify proper initialization.
*
* _cpri__HashStartup() - not doing anything for now, maybe hw
* reinitialization is required?
* _cpri__RsaStartup() - not sure what needs to be done in HW
* _cpri__EccStartup() - not sure what needs to be done in HW
* _cpri__SymStartup() - this function is emtpy in the TPM2 library
* implementation.
*/
return 1;
}
CRYPT_RESULT _cpri__TestKeyRSA(
TPM2B * d, // OUT: the address to receive the
// private exponent
UINT32 exponent, // IN: the public modulu
TPM2B * publicKey, // IN/OUT: an input if only one prime is
// provided. an output if both primes are provided
TPM2B * prime1, // IN: a first prime
TPM2B * prime2 // IN: an optional second prime
)
{
ecprintf("%s called\n", __func__);
return CRYPT_FAIL;
}
CRYPT_RESULT _math__Div(
const TPM2B * n, // IN: numerator
const TPM2B * d, // IN: denominator
TPM2B * q, // OUT: quotient
TPM2B * r // OUT: remainder
)
{
ecprintf("%s called\n", __func__);
return CRYPT_FAIL;
}
void __assert_func(
const char *file,
int line,
const char *func,
const char *condition
)
{
/*
* TPM2 library invokes assert from a common wrapper, which first sets
* global variables describing the failure point and then invokes the
* assert() macro which ends up calling this function as defined by the gcc
* toolchain.
*
* For some weird reason (or maybe this is a bug), s_FailFunction is defined
* in the tpm2 library as a 32 bit int, but on a failure the name of the
* failing function (its first four bytes) are copiied into this variable.
*
* TODO(vbendeb): investigate and fix TPM2 library assert handling.
*/
ecprintf("Failure in %s, func %s, line %d:\n%s\n",
file,
s_failFunction ? (const char *)&s_failFunction : func,
s_failLine ? s_failLine : line,
condition);
while (1)
; /* Let the watchdog doo the rest. */
}
CRYPT_RESULT _cpri__InitCryptoUnits(
FAIL_FUNCTION failFunction)
{
return CRYPT_SUCCESS;
}
|