blob: 8061584ffdee792e41ec775e11ee222bd677404b [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_CPRIECC_FP_H
8#define __TPM2_CPRIECC_FP_H
9
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070010LIB_EXPORT CRYPT_RESULT _cpri__C_2_2_KeyExchange(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070011 TPMS_ECC_POINT *outZ1, // OUT: a computed point
12 TPMS_ECC_POINT *outZ2, // OUT: and optional second point
13 TPM_ECC_CURVE curveId, // IN: the curve for the computations
14 TPM_ALG_ID scheme, // IN: the key exchange scheme
15 TPM2B_ECC_PARAMETER *dsA, // IN: static private TPM key
16 TPM2B_ECC_PARAMETER *deA, // IN: ephemeral private TPM key
17 TPMS_ECC_POINT *QsB, // IN: static public party B key
18 TPMS_ECC_POINT *QeB // IN: ephemeral public party B key
19 );
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070020LIB_EXPORT CRYPT_RESULT _cpri__EccCommitCompute(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070021 TPMS_ECC_POINT *K, // OUT: [d]B or [r]Q
22 TPMS_ECC_POINT *L, // OUT: [r]B
23 TPMS_ECC_POINT *E, // OUT: [r]M
24 TPM_ECC_CURVE curveId, // IN: the curve for the computations
25 TPMS_ECC_POINT *M, // IN: M (optional)
26 TPMS_ECC_POINT *B, // IN: B (optional)
27 TPM2B_ECC_PARAMETER *d, // IN: d (required)
28 TPM2B_ECC_PARAMETER *r // IN: the computed r value (required)
29 );
30LIB_EXPORT UINT32 _cpri__EccGetCurveCount(void);
31LIB_EXPORT const ECC_CURVE *_cpri__EccGetParametersByCurveId(
32 TPM_ECC_CURVE curveId // IN: the curveID
33 );
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070034LIB_EXPORT CRYPT_RESULT _cpri__EccPointMultiply(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070035 TPMS_ECC_POINT *Rout, // OUT: the product point R
36 TPM_ECC_CURVE curveId, // IN: the curve to use
37 TPM2B_ECC_PARAMETER *
38 dIn, // IN: value to multiply against the curve generator
39 TPMS_ECC_POINT *Qin, // IN: point Q
40 TPM2B_ECC_PARAMETER *uIn // IN: scalar value for the multiplier of Q
41 );
42LIB_EXPORT BOOL
43_cpri__EccIsPointOnCurve(TPM_ECC_CURVE curveId, // IN: the curve selector
44 TPMS_ECC_POINT *Q // IN: the point.
45 );
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070046LIB_EXPORT CRYPT_RESULT _cpri__GenerateKeyEcc(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070047 TPMS_ECC_POINT *Qout, // OUT: the public point
48 TPM2B_ECC_PARAMETER *dOut, // OUT: the private scalar
49 TPM_ECC_CURVE curveId, // IN: the curve identifier
50 TPM_ALG_ID
51 hashAlg, // IN: hash algorithm to use in the key generation process
52 TPM2B *seed, // IN: the seed to use
53 const char *label, // IN: A label for the generation process.
54 TPM2B *extra, // IN: Party 1 data for the KDF
55 UINT32 *counter // IN/OUT: Counter value to allow KDF iteration to be
56 // propagated across multiple functions
57 );
58LIB_EXPORT TPM_ECC_CURVE _cpri__GetCurveIdByIndex(UINT16 i);
59LIB_EXPORT CRYPT_RESULT
60_cpri__GetEphemeralEcc(TPMS_ECC_POINT *Qout, // OUT: the public point
61 TPM2B_ECC_PARAMETER *dOut, // OUT: the private scalar
62 TPM_ECC_CURVE curveId // IN: the curve for the key
63 );
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070064LIB_EXPORT CRYPT_RESULT _cpri__SignEcc(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070065 TPM2B_ECC_PARAMETER *rOut, // OUT: r component of the signature
66 TPM2B_ECC_PARAMETER *sOut, // OUT: s component of the signature
67 TPM_ALG_ID scheme, // IN: the scheme selector
68 TPM_ALG_ID hashAlg, // IN: the hash algorithm if need
69 TPM_ECC_CURVE curveId, // IN: the curve used in the signature process
70 TPM2B_ECC_PARAMETER *dIn, // IN: the private key
71 TPM2B *digest, // IN: the digest to sign
72 TPM2B_ECC_PARAMETER *kIn // IN: k for input
73 );
Vadim Bendeburyfea3a142015-05-28 18:53:22 -070074LIB_EXPORT BOOL _cpri__EccStartup(void);
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070075LIB_EXPORT CRYPT_RESULT _cpri__ValidateSignatureEcc(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070076 TPM2B_ECC_PARAMETER *rIn, // IN: r component of the signature
77 TPM2B_ECC_PARAMETER *sIn, // IN: s component of the signature
78 TPM_ALG_ID scheme, // IN: the scheme selector
79 TPM_ALG_ID
80 hashAlg, // IN: the hash algorithm used (not used in all schemes)
81 TPM_ECC_CURVE curveId, // IN: the curve used in the signature process
82 TPMS_ECC_POINT *Qin, // IN: the public point of the key
83 TPM2B *digest // IN: the digest that was signed
84 );
Vadim Bendeburyfea3a142015-05-28 18:53:22 -070085
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070086#endif // __TPM2_CPRIECC_FP_H