Internal interface that models TPM 2.0 interfaces. More...
Functions | |
EpidStatus | Tpm2Commit (Tpm2Ctx *ctx, EcPoint const *p1, void const *s2, size_t s2_len, FfElement const *y2, EcPoint *k, EcPoint *l, EcPoint *e, uint16_t *counter) |
Performs TPM2_Commit TPM operation. More... | |
EpidStatus | Tpm2CreateContext (MemberParams const *params, Epid2Params_ const *epid2_params, BitSupplier *rnd_func, void **rnd_param, const FpElemStr **f, Tpm2Ctx **ctx) |
Creates a new Tpm context. More... | |
void | Tpm2DeleteContext (Tpm2Ctx **ctx) |
Deletes an existing Tpm context. More... | |
EpidStatus | Tpm2SetHashAlg (Tpm2Ctx *ctx, HashAlg hash_alg) |
Sets the hash algorithm to be used by a TPM2. More... | |
void | Tpm2ResetContext (Tpm2Ctx **ctx) |
Reset an existing Tpm context. More... | |
EpidStatus | Tpm2GetRandom (Tpm2Ctx *ctx, int const num_bits, void *random_data) |
Get random data. More... | |
EpidStatus | Tpm2LoadExternal (Tpm2Ctx *ctx, FpElemStr const *f_str) |
Invokes TPM2_LoadExternal command. More... | |
EpidStatus | Tpm2NvDefineSpace (Tpm2Ctx *ctx, uint32_t nv_index, size_t size) |
Performs TPM2_NV_DefineSpace TPM command. More... | |
EpidStatus | Tpm2NvUndefineSpace (Tpm2Ctx *ctx, uint32_t nv_index) |
Performs TPM2_NV_UndefineSpace TPM command. More... | |
EpidStatus | Tpm2NvWrite (Tpm2Ctx *ctx, uint32_t nv_index, size_t size, uint16_t offset, void const *data) |
Performs TPM2_NV_Write TPM command. More... | |
EpidStatus | Tpm2NvRead (Tpm2Ctx *ctx, uint32_t nv_index, size_t size, uint16_t offset, void *data) |
Performs TPM2_NV_Read TPM command. More... | |
EpidStatus | Tpm2Sign (Tpm2Ctx *ctx, void const *digest, size_t digest_len, uint16_t counter, FfElement *k, FfElement *s) |
Performs TPM2_Sign TPM command. More... | |
EpidStatus | Tpm2ReleaseCounter (Tpm2Ctx *ctx, uint16_t counter) |
Erases random r value assosiated with counter. More... | |
Internal interface that models TPM 2.0 interfaces.
Provides an interface that represents operations that can be directly translated to operations on TPM 2.0 devices.
EpidStatus Tpm2Commit | ( | Tpm2Ctx * | ctx, |
EcPoint const * | p1, | ||
void const * | s2, | ||
size_t | s2_len, | ||
FfElement const * | y2, | ||
EcPoint * | k, | ||
EcPoint * | l, | ||
EcPoint * | e, | ||
uint16_t * | counter | ||
) |
Performs TPM2_Commit TPM operation.
Generates random r and compute K, L and E points.
[in] | ctx | The TPM context. |
[in] | p1 | A point P1 on G1 curve. |
[in] | s2 | Octet array used to derive x-coordinate of a point P2. |
[in] | s2_len | Length of s2 buffer. |
[in] | y2 | y coordinate of the point associated with s2. |
[out] | k | Result of G1.exp(P2, private key f). |
[out] | l | Result of G1.exp(P2, random r). |
[out] | e | Result of G1.exp(P1, random r). |
[out] | counter | A value associated with the random r. Should be initialized with zero. |
EpidStatus Tpm2CreateContext | ( | MemberParams const * | params, |
Epid2Params_ const * | epid2_params, | ||
BitSupplier * | rnd_func, | ||
void ** | rnd_param, | ||
const FpElemStr ** | f, | ||
Tpm2Ctx ** | ctx | ||
) |
Creates a new Tpm context.
Must be called to create the TPM context that is used by other TPM APIs.
You need to use a cryptographically secure random number generator to create a TPM context. The BitSupplier is provided as a function prototype for your own implementation of the random number generator.
Tpm2DeleteContext must be called to safely release the TPM context.
[in] | params | member parameters to initialize rnd_func, rnd_param, ff_elem, ctx. |
[in] | epid2_params | The field and group parameters. |
[out] | rnd_func | random function if exists in MemberParms |
[out] | rnd_param | random parameters if exists in MemberParms |
[out] | f | seed f if exists in MemberParams |
[out] | ctx | Newly constructed TPM context. |
void Tpm2DeleteContext | ( | Tpm2Ctx ** | ctx | ) |
Deletes an existing Tpm context.
Must be called to safely release a TPM context created using Tpm2CreateContext.
De-initializes the context, frees memory used by the context, and sets the context pointer to NULL.
[in,out] | ctx | The TPM context. Can be NULL. |
EpidStatus Tpm2GetRandom | ( | Tpm2Ctx * | ctx, |
int const | num_bits, | ||
void * | random_data | ||
) |
Get random data.
This command returns the next num_bits from the random number generator (RNG).
[in,out] | ctx | TPM context. |
[in] | num_bits | Number of bits to return. |
[out] | random_data | Output random bits. |
EpidStatus Tpm2LoadExternal | ( | Tpm2Ctx * | ctx, |
FpElemStr const * | f_str | ||
) |
Invokes TPM2_LoadExternal command.
This command is used to load an object that is not a Protected Object into the TPM. The command allows loading of a public area or both a public and sensitive area.
[in,out] | ctx | TPM context. |
[in] | f_str | The f value of the member private key. |
EpidStatus Tpm2NvDefineSpace | ( | Tpm2Ctx * | ctx, |
uint32_t | nv_index, | ||
size_t | size | ||
) |
Performs TPM2_NV_DefineSpace TPM command.
[in] | ctx | The TPM context. |
[in] | nv_index | Handle of the data area. |
[in] | size | Size of the data area. |
EpidStatus Tpm2NvRead | ( | Tpm2Ctx * | ctx, |
uint32_t | nv_index, | ||
size_t | size, | ||
uint16_t | offset, | ||
void * | data | ||
) |
Performs TPM2_NV_Read TPM command.
[in] | ctx | The TPM context. |
[in] | nv_index | NV Index to be read. |
[in] | size | Number of bytes to read. |
[in] | offset | Offset into the area. |
[out] | data | Data read. |
EpidStatus Tpm2NvUndefineSpace | ( | Tpm2Ctx * | ctx, |
uint32_t | nv_index | ||
) |
Performs TPM2_NV_UndefineSpace TPM command.
[in] | ctx | The TPM context. |
[in] | nv_index | Handle of the data area to undefine. |
EpidStatus Tpm2NvWrite | ( | Tpm2Ctx * | ctx, |
uint32_t | nv_index, | ||
size_t | size, | ||
uint16_t | offset, | ||
void const * | data | ||
) |
Performs TPM2_NV_Write TPM command.
An area in NV memory must be defined prior writing.
[in] | ctx | The TPM context. |
[in] | nv_index | NV Index to be write. |
[in] | size | Number of bytes to write. |
[in] | offset | Offset into the area. |
[in] | data | Data to write. |
EpidStatus Tpm2ReleaseCounter | ( | Tpm2Ctx * | ctx, |
uint16_t | counter | ||
) |
Erases random r value assosiated with counter.
[in] | ctx | The TPM context. |
[in] | counter | To be released value associated with the random r generated during TPM2_Commit. |
void Tpm2ResetContext | ( | Tpm2Ctx ** | ctx | ) |
Reset an existing Tpm context.
Must be called to reset a TPM context created using Tpm2CreateContext.
Re-initializes the context, reset memory used for primary key.
[in,out] | ctx | The TPM context. Can be NULL. |
EpidStatus Tpm2SetHashAlg | ( | Tpm2Ctx * | ctx, |
HashAlg | hash_alg | ||
) |
Sets the hash algorithm to be used by a TPM2.
[in] | ctx | The TPM2 context. |
[in] | hash_alg | The hash algorithm to use. |
EpidStatus Tpm2Sign | ( | Tpm2Ctx * | ctx, |
void const * | digest, | ||
size_t | digest_len, | ||
uint16_t | counter, | ||
FfElement * | k, | ||
FfElement * | s | ||
) |
Performs TPM2_Sign TPM command.
Calculate a pair (k, s) an ECDAA signature.
Private key f must exist in the TPM context.
[in] | ctx | The TPM context. |
[in] | digest | Digest to be signed. |
[in] | digest_len | The size of digest in bytes. |
[in] | counter | A value associated with the random r generated during TPM2_Commit. |
[out] | k | The ECDAA signature k value. Nonce produced by the TPM during signing. |
[out] | s | The ECDAA signature s value. |