Home | History | Annotate | Download | only in tpm2
      1 /*
      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 
     10 LIB_EXPORT CRYPT_RESULT _cpri__C_2_2_KeyExchange(
     11     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     );
     20 LIB_EXPORT CRYPT_RESULT _cpri__C_2_2_KeyExchange(
     21     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     );
     30 LIB_EXPORT CRYPT_RESULT _cpri__EccCommitCompute(
     31     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     );
     40 LIB_EXPORT UINT32 _cpri__EccGetCurveCount(void);
     41 LIB_EXPORT const ECC_CURVE *_cpri__EccGetParametersByCurveId(
     42     TPM_ECC_CURVE curveId  // IN: the curveID
     43     );
     44 LIB_EXPORT CRYPT_RESULT _cpri__EccPointMultiply(
     45     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     );
     52 LIB_EXPORT BOOL
     53 _cpri__EccIsPointOnCurve(TPM_ECC_CURVE curveId,  // IN: the curve selector
     54                          TPMS_ECC_POINT *Q       // IN: the point.
     55                          );
     56 LIB_EXPORT CRYPT_RESULT _cpri__GenerateKeyEcc(
     57     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     );
     68 LIB_EXPORT TPM_ECC_CURVE _cpri__GetCurveIdByIndex(UINT16 i);
     69 LIB_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                        );
     74 LIB_EXPORT CRYPT_RESULT _cpri__SignEcc(
     75     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     );
     84 LIB_EXPORT BOOL _cpri__EccStartup(void);
     85 LIB_EXPORT CRYPT_RESULT _cpri__ValidateSignatureEcc(
     86     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     );
     95 
     96 #endif  // __TPM2_CPRIECC_FP_H
     97