@@ -564,14 +564,88 @@ typedef struct FWTPM_CTX {
564564#endif
565565} FWTPM_CTX ;
566566
567- /* Public API */
567+ /** @defgroup wolfTPM_fwTPM wolfTPM fwTPM (Firmware TPM)
568+ *
569+ * Public API for the wolfTPM firmware TPM (fwTPM) software TPM 2.0
570+ * implementation. fwTPM is a portable TPM server that speaks the
571+ * TCG TPM 2.0 command protocol and can run alongside or in place of
572+ * a hardware TPM. Transports are pluggable (sockets, TIS shared memory,
573+ * SPI/UART on embedded targets) via HAL callbacks. Storage (NV) and
574+ * clock are also pluggable so the same core can run on Linux and
575+ * bare-metal microcontrollers.
576+ */
577+
578+ /*!
579+ \ingroup wolfTPM_fwTPM
580+ \brief Initialize a fwTPM context. Seeds the RNG, clears TPM state,
581+ and prepares the context for FWTPM_NV_Init / FWTPM_IO_Init.
582+
583+ \return 0 on success
584+ \return TPM_RC_MEMORY if RNG initialization fails
585+
586+ \param ctx pointer to caller-allocated FWTPM_CTX (must be zeroed)
587+
588+ \sa FWTPM_Cleanup
589+ \sa FWTPM_NV_SetHAL
590+ \sa FWTPM_Clock_SetHAL
591+ */
568592WOLFTPM_API int FWTPM_Init (FWTPM_CTX * ctx );
593+
594+ /*!
595+ \ingroup wolfTPM_fwTPM
596+ \brief Release resources held by a fwTPM context. Zeros all
597+ hierarchy seeds, session keys, and sensitive auth values before
598+ freeing. Safe to call on a partially-initialized context.
599+
600+ \return 0 on success
601+
602+ \param ctx pointer to an initialized FWTPM_CTX
603+
604+ \sa FWTPM_Init
605+ */
569606WOLFTPM_API int FWTPM_Cleanup (FWTPM_CTX * ctx );
607+
608+ /*!
609+ \ingroup wolfTPM_fwTPM
610+ \brief Return a pointer to the compile-time fwTPM version string
611+ (e.g. "0.1.0").
612+
613+ \return pointer to a static, null-terminated version string
614+ */
570615WOLFTPM_API const char * FWTPM_GetVersionString (void );
571616
572- /* Clock HAL API */
617+ /*!
618+ \ingroup wolfTPM_fwTPM
619+ \brief Register a platform clock source for fwTPM. On embedded
620+ targets this allows the TPM clock (TPM2_ReadClock / TPM2_ClockSet)
621+ to advance from a hardware timer. When no HAL is registered,
622+ FWTPM_Clock_GetMs returns ctx->clockOffset only.
623+
624+ \return 0 on success
625+ \return BAD_FUNC_ARG if ctx is NULL
626+
627+ \param ctx pointer to an initialized FWTPM_CTX
628+ \param get_ms callback returning milliseconds-since-boot; may be NULL
629+ to clear a previously registered HAL
630+ \param halCtx opaque context passed back to get_ms
631+
632+ \sa FWTPM_Clock_GetMs
633+ */
573634WOLFTPM_API int FWTPM_Clock_SetHAL (FWTPM_CTX * ctx ,
574635 UINT64 (* get_ms )(void * halCtx ), void * halCtx );
636+
637+ /*!
638+ \ingroup wolfTPM_fwTPM
639+ \brief Get the current TPM clock value in milliseconds. Returns
640+ ctx->clockOffset plus (if registered) the value from the clock HAL.
641+
642+ \return current clock value in milliseconds
643+ \return 0 if ctx is NULL
644+
645+ \param ctx pointer to an initialized FWTPM_CTX
646+
647+ \sa FWTPM_Clock_SetHAL
648+ */
575649WOLFTPM_API UINT64 FWTPM_Clock_GetMs (FWTPM_CTX * ctx );
576650
577651#ifdef __cplusplus
0 commit comments