1 // This file was extracted from the TCG Published
2 // Trusted Platform Module Library
3 // Part 3: Commands
4 // Family "2.0"
5 // Level 00 Revision 01.16
6 // October 30, 2014
7 
8 #include "InternalRoutines.h"
9 #include "EC_Ephemeral_fp.h"
10 #ifdef TPM_ALG_ECC
11 //
12 //
13 //     Error Returns                    Meaning
14 //
15 //     none                             ...
16 //
17 TPM_RC
TPM2_EC_Ephemeral(EC_Ephemeral_In * in,EC_Ephemeral_Out * out)18 TPM2_EC_Ephemeral(
19    EC_Ephemeral_In       *in,               // IN: input parameter list
20    EC_Ephemeral_Out      *out               // OUT: output parameter list
21    )
22 {
23    TPM2B_ECC_PARAMETER          r;
24 
25    // Get the random value that will be used in the point multiplications
26    // Note: this does not commit the count.
27    if(!CryptGenerateR(&r,
28                       NULL,
29                       in->curveID,
30                       NULL))
31        return TPM_RC_NO_RESULT;
32 
33    CryptEccPointMultiply(&out->Q.t.point, in->curveID, &r, NULL);
34 
35    // commit the count value
36    out->counter = CryptCommit();
37 
38    return TPM_RC_SUCCESS;
39 }
40 #endif
41