blob: 619ed0efd8053982cd773ec97a5033b5f1086750 [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__C_2_2_KeyExchange(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070021 TPMS_ECC_POINT *outZ1, // OUT: a computed point
22 TPMS_ECC_POINT *outZ2, // OUT: and optional second point
23 TPM_ECC_CURVE curveId, // IN: the curve for the computations
24 TPM_ALG_ID scheme, // IN: the key exchange scheme
25 TPM2B_ECC_PARAMETER *dsA, // IN: static private TPM key
26 TPM2B_ECC_PARAMETER *deA, // IN: ephemeral private TPM key
27 TPMS_ECC_POINT *QsB, // IN: static public party B key
28 TPMS_ECC_POINT *QeB // IN: ephemeral public party B key
29 );
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070030LIB_EXPORT CRYPT_RESULT _cpri__EccCommitCompute(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070031 TPMS_ECC_POINT *K, // OUT: [d]B or [r]Q
32 TPMS_ECC_POINT *L, // OUT: [r]B
33 TPMS_ECC_POINT *E, // OUT: [r]M
34 TPM_ECC_CURVE curveId, // IN: the curve for the computations
35 TPMS_ECC_POINT *M, // IN: M (optional)
36 TPMS_ECC_POINT *B, // IN: B (optional)
37 TPM2B_ECC_PARAMETER *d, // IN: d (required)
38 TPM2B_ECC_PARAMETER *r // IN: the computed r value (required)
39 );
40LIB_EXPORT UINT32 _cpri__EccGetCurveCount(void);
41LIB_EXPORT const ECC_CURVE *_cpri__EccGetParametersByCurveId(
42 TPM_ECC_CURVE curveId // IN: the curveID
43 );
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070044LIB_EXPORT CRYPT_RESULT _cpri__EccPointMultiply(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070045 TPMS_ECC_POINT *Rout, // OUT: the product point R
46 TPM_ECC_CURVE curveId, // IN: the curve to use
47 TPM2B_ECC_PARAMETER *
48 dIn, // IN: value to multiply against the curve generator
49 TPMS_ECC_POINT *Qin, // IN: point Q
50 TPM2B_ECC_PARAMETER *uIn // IN: scalar value for the multiplier of Q
51 );
52LIB_EXPORT BOOL
53_cpri__EccIsPointOnCurve(TPM_ECC_CURVE curveId, // IN: the curve selector
54 TPMS_ECC_POINT *Q // IN: the point.
55 );
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070056LIB_EXPORT CRYPT_RESULT _cpri__GenerateKeyEcc(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070057 TPMS_ECC_POINT *Qout, // OUT: the public point
58 TPM2B_ECC_PARAMETER *dOut, // OUT: the private scalar
59 TPM_ECC_CURVE curveId, // IN: the curve identifier
60 TPM_ALG_ID
61 hashAlg, // IN: hash algorithm to use in the key generation process
62 TPM2B *seed, // IN: the seed to use
63 const char *label, // IN: A label for the generation process.
64 TPM2B *extra, // IN: Party 1 data for the KDF
65 UINT32 *counter // IN/OUT: Counter value to allow KDF iteration to be
66 // propagated across multiple functions
67 );
68LIB_EXPORT TPM_ECC_CURVE _cpri__GetCurveIdByIndex(UINT16 i);
69LIB_EXPORT CRYPT_RESULT
70_cpri__GetEphemeralEcc(TPMS_ECC_POINT *Qout, // OUT: the public point
71 TPM2B_ECC_PARAMETER *dOut, // OUT: the private scalar
72 TPM_ECC_CURVE curveId // IN: the curve for the key
73 );
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070074LIB_EXPORT CRYPT_RESULT _cpri__SignEcc(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070075 TPM2B_ECC_PARAMETER *rOut, // OUT: r component of the signature
76 TPM2B_ECC_PARAMETER *sOut, // OUT: s component of the signature
77 TPM_ALG_ID scheme, // IN: the scheme selector
78 TPM_ALG_ID hashAlg, // IN: the hash algorithm if need
79 TPM_ECC_CURVE curveId, // IN: the curve used in the signature process
80 TPM2B_ECC_PARAMETER *dIn, // IN: the private key
81 TPM2B *digest, // IN: the digest to sign
82 TPM2B_ECC_PARAMETER *kIn // IN: k for input
83 );
Vadim Bendeburyfea3a142015-05-28 18:53:22 -070084LIB_EXPORT BOOL _cpri__EccStartup(void);
Vadim Bendeburyc00055c2015-05-29 22:50:18 -070085LIB_EXPORT CRYPT_RESULT _cpri__ValidateSignatureEcc(
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070086 TPM2B_ECC_PARAMETER *rIn, // IN: r component of the signature
87 TPM2B_ECC_PARAMETER *sIn, // IN: s component of the signature
88 TPM_ALG_ID scheme, // IN: the scheme selector
89 TPM_ALG_ID
90 hashAlg, // IN: the hash algorithm used (not used in all schemes)
91 TPM_ECC_CURVE curveId, // IN: the curve used in the signature process
92 TPMS_ECC_POINT *Qin, // IN: the public point of the key
93 TPM2B *digest // IN: the digest that was signed
94 );
Vadim Bendeburyfea3a142015-05-28 18:53:22 -070095
Vadim Bendeburyf788ffb2015-06-05 12:57:27 -070096#endif // __TPM2_CPRIECC_FP_H