Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Applications](https://optee.readthedocs.io/en/latest/building/trusted_applicatio
section in the [OP-TEE
documentation](https://optee.readthedocs.io/en/latest/index.html) with the
addition of `CFG_MS_TPM_20_REF` which must hold the path to a checked out
copy of the [MS TPM 2.0 Reference
Implementation](https://github.com/microsoft/ms-tpm-20-ref).
You need to checkout commit (98b60a44aba79b15fcce1c0d1e46cf5918400f6a) of [MS TPM 2.0 Reference
Implementation](https://github.com/microsoft/ms-tpm-20-ref)
copy of the [The Official TPM 2.0 Reference
Implementation](https://github.com/TrustedComputingGroup/TPM).
For the time being and until The Official TPM 2.0 Reference Implementation accepts a corresponding pull request
the following fixed version is required: https://github.com/svenbauer-work/TPM/tree/a9665960ddfb92b8a140cd8d37d29342ddb05b3b

## Measured Boot support
The fTPM Trusted Application includes support for Measured Boot. This
Expand Down
29 changes: 16 additions & 13 deletions include/TEE/TpmToTEEMath.h → include/TEE/BnToTEEMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,25 @@
* are defined in TpmTypes.h
*/

#ifndef MATH_LIB_DEFINED
#define MATH_LIB_DEFINED
#ifndef BN_MATH_LIB_DEFINED
#define BN_MATH_LIB_DEFINED

#define MATH_LIB_TEE
#define BN_MATH_LIB_TEE

typedef ECC_CURVE_DATA bnCurve_t;
/*#define CRYPT_INT_BUF(buftypename, bits) BN_STRUCT_DEF(buftypename, bits)
#define CRYPT_POINT_BUF(buftypename, bits) BN_POINT_BUF(buftypename, bits)
#define CRYPT_CURVE_BUF(buftypename, bits) TPMBN_ECC_CURVE_CONSTANTS*/

typedef bnCurve_t* bigCurve;
typedef struct crypto_impl_description
{
} _CRYPTO_IMPL_DESCRIPTION;

#define SYMMETRIC_ALIGNMENT RADIX_BYTES
typedef const TPMBN_ECC_CURVE_CONSTANTS* bigCurveData;

#define AccessCurveData(E) (E)
TPM_INLINE const TPMBN_ECC_CURVE_CONSTANTS* AccessCurveConstants(
const bigCurveData* E)
{
return *E;
}

#define CURVE_INITIALIZED(name, initializer) \
bnCurve_t* name = (ECC_CURVE_DATA*)GetCurveData(initializer)

#define CURVE_FREE(E)

#endif /*MATH_LIB_DEFINED*/
#endif /*BN_MATH_LIB_DEFINED*/
11 changes: 2 additions & 9 deletions include/fTPM.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2024, Linaro Limited
* Copyright (c) 2026, Siemens AG
*/

/* Microsoft Reference Implementation for TPM 2.0
Expand Down Expand Up @@ -43,15 +44,9 @@
#ifndef FTPM_H
#define FTPM_H

#include <TpmProfile.h>
#include <TpmConfiguration/TpmProfile.h>
#include <ftpm_ta.h>

//
// These must match values from reference/TPM/include/TpmProfile.h
//
#define MAX_COMMAND_SIZE 4096
#define MAX_RESPONSE_SIZE 4096

//
// Macro for intentionally unreferenced parameters
//
Expand Down Expand Up @@ -85,11 +80,9 @@ extern void ExecuteCommand(
//
// External functions supporting TPM initialization
//
extern int _plat__NVEnable(void *platParameter);
extern int TPM_Manufacture(bool firstTime);
extern bool _plat__NvNeedsManufacture(void);
extern void _TPM_Init(void);
extern void _plat__NVDisable(void);
extern void _admin__SaveChipFlags(void);

//
Expand Down
5 changes: 3 additions & 2 deletions include/user_ta_header_defines.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2024, Linaro Limited
* Copyright (c) 2026, Siemens AG
*/

/* Microsoft Reference Implementation for TPM 2.0
Expand Down Expand Up @@ -55,8 +56,8 @@
TA_FLAG_INSTANCE_KEEP_ALIVE | \
TA_FLAG_INSTANCE_KEEP_CRASHED | \
TA_FLAG_DEVICE_ENUM_TEE_STORAGE_PRIVATE)
#define TA_STACK_SIZE (64 * 1024)
#define TA_DATA_SIZE (32 * 1024)
#define TA_STACK_SIZE (128 * 1024)
#define TA_DATA_SIZE (64 * 1024)

#define TA_VERSION "0.1"
#define TA_DESCRIPTION "fTPM TA"
Expand Down
5 changes: 3 additions & 2 deletions platform/AdminPPI.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2024, Linaro Limited
* Copyright (c) 2026, Siemens AG
*/
/* Microsoft Reference Implementation for TPM 2.0
*
Expand Down Expand Up @@ -240,7 +241,7 @@ _admin__PPIRequest(
{
TPM2_EmulatePPI_cmd_t cmd;
TPM2_EmulatePPI_res_t rsp;
TPM2_EmulatePPI_res_t *rspPtr = &rsp;
UINT8 *rspPtr = (void *)&rsp;
UINT32 rspLen = sizeof(TPM2_EmulatePPI_res_t);
UINT8 *CmdBuffer;

Expand Down Expand Up @@ -272,7 +273,7 @@ _admin__PPIRequest(
if (!_admin__PPICommand(sizeof(TPM2_EmulatePPI_cmd_t),
(UINT8 *)&cmd,
&rspLen,
(UINT8**)&rspPtr)) {
&rspPtr)) {
return 0;
}

Expand Down
9 changes: 7 additions & 2 deletions platform/Cancel.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2026, Siemens AG
*/
/* Microsoft Reference Implementation for TPM 2.0
*
* The copyright in this software is being made available under the BSD License,
Expand Down Expand Up @@ -38,7 +42,8 @@
//
//** Includes, Typedefs, Structures, and Defines
#include "PlatformData.h"
#include "Platform_fp.h"
#include "platform_interface/tpm_to_platform_interface.h"
#include "prototypes/platform_public_interface.h"

//** Functions

Expand Down Expand Up @@ -77,4 +82,4 @@ _plat__ClearCancel(
{
s_isCanceled = FALSE;
return;
}
}
38 changes: 19 additions & 19 deletions platform/Clock.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2026, Siemens AG
*/
/* Microsoft Reference Implementation for TPM 2.0
*
* The copyright in this software is being made available under the BSD License,
Expand Down Expand Up @@ -42,8 +46,9 @@

//** Includes and Data Definitions
#include "PlatformData.h"
#include "Platform_fp.h"
#include "TpmFail_fp.h"
#include "platform_interface/tpm_to_platform_interface.h"
#include "prototypes/platform_public_interface.h"
#include "tpm_public/prototypes/TpmFail_fp.h"
#include <assert.h>
#include <tee_internal_api.h>

Expand Down Expand Up @@ -259,36 +264,31 @@ _plat__TimerWasStopped(

//***_plat__ClockAdjustRate()
// Adjust the clock rate
LIB_EXPORT void
_plat__ClockAdjustRate(
int adjust // IN: the adjust number. It could be positive
// or negative
)
LIB_EXPORT void _plat__ClockRateAdjust(_plat__ClockAdjustStep adjust)
{
// We expect the caller should only use a fixed set of constant values to
// adjust the rate
switch(adjust)
{
case CLOCK_ADJUST_COARSE:
// slower increases the divisor
case PLAT_TPM_CLOCK_ADJUST_COARSE_SLOWER:
s_adjustRate += CLOCK_ADJUST_COARSE;
break;
case -CLOCK_ADJUST_COARSE:
s_adjustRate -= CLOCK_ADJUST_COARSE;
break;
case CLOCK_ADJUST_MEDIUM:
case PLAT_TPM_CLOCK_ADJUST_MEDIUM_SLOWER:
s_adjustRate += CLOCK_ADJUST_MEDIUM;
break;
case -CLOCK_ADJUST_MEDIUM:
s_adjustRate -= CLOCK_ADJUST_MEDIUM;
break;
case CLOCK_ADJUST_FINE:
case PLAT_TPM_CLOCK_ADJUST_FINE_SLOWER:
s_adjustRate += CLOCK_ADJUST_FINE;
break;
case -CLOCK_ADJUST_FINE:
// faster decreases the divisor
case PLAT_TPM_CLOCK_ADJUST_FINE_FASTER:
s_adjustRate -= CLOCK_ADJUST_FINE;
break;
default:
// ignore any other values;
case PLAT_TPM_CLOCK_ADJUST_MEDIUM_FASTER:
s_adjustRate -= CLOCK_ADJUST_MEDIUM;
break;
case PLAT_TPM_CLOCK_ADJUST_COARSE_FASTER:
s_adjustRate -= CLOCK_ADJUST_COARSE;
break;
}

Expand Down
97 changes: 0 additions & 97 deletions platform/EPS.c

This file was deleted.

9 changes: 7 additions & 2 deletions platform/Entropy.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (c) 2026, Siemens AG
*/
/* Microsoft Reference Implementation for TPM 2.0
*
* The copyright in this software is being made available under the BSD License,
Expand Down Expand Up @@ -38,7 +42,8 @@
#include <stdlib.h>
#include <memory.h>
#include "PlatformData.h"
#include "Platform_fp.h"
#include "platform_interface/tpm_to_platform_interface.h"
#include "prototypes/platform_public_interface.h"
#include <time.h>

#include <tee_internal_api.h>
Expand Down Expand Up @@ -125,4 +130,4 @@ _plat__GetEntropy(
}
}
return ret;
}
}
Loading