Hello,
I agree that this looks like a mistake. The various platform interfaces
are subtly different, and I suspect that this was inspired by a similar
check for a different interface that doesn't apply here. This is not
tested (I think we have no tests for custom platform types).
Can you please submit a patch?
--
Best regards,
Gilles Peskine
TF-PSA-Crypto and Mbed TLS developer
On 18/07/2026 15:15, Huber, Ralf via mbed-tls wrote:
>
> Dear Mbed TLS contributors,
>
> We are using mbedtls v4 for X.509 certificate verification on a 32 bit
> microcontroller. The device has an RTC chip and we use its time for
> mbedtls by defining MBEDTLS_PLATFORM_TIME_ALT. This is working so far.
>
> The compiler provides <time.h>, with time_t being a signed 32 bit
> type. I would like to stop mbedtls from using the date and time
> functions of <time.h> and change mbedtls_time_t to _unsigned_ 32 bit
> to avoid the year 2038 problem (when signed 32 bit time_t will
> overflow). To do this, I defined
>
> #define MBEDTLS_PLATFORM_TIME_TYPE_MACRO unsigned long
>
> I also changed the custom time function (MBEDTLS_PLATFORM_TIME_ALT) to
> return unsigned values and I defined MBEDTLS_PLATFORM_GMTIME_R_ALT and
> provided a custom mbedtls_platform_gmtime_r() that accepts unsigned
> values.
>
> When I build mbedtls with these settings, I get an error from
> tf_psa_crypto_check_config.h:
>
> #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\
>
> ( defined(MBEDTLS_PLATFORM_STD_TIME) ||\
>
> defined(MBEDTLS_PLATFORM_TIME_ALT) )
>
> #error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO and
> MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined
> simultaneously"
>
> #endif
>
> I wonder if this check is actually necessary or maybe a mistake?
> Actually, I expected the opposite, i.e.
>
> #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\
>
> !( defined(MBEDTLS_PLATFORM_STD_TIME) ||\
>
> defined(MBEDTLS_PLATFORM_TIME_ALT) )
>
> #error "Must provide alternate time() function compatible with type
> defined by MBEDTLS_PLATFORM_TIME_TYPE_MACRO"
>
> #endif
>
> Could somebody please explain why MBEDTLS_PLATFORM_TIME_TYPE_MACRO
> can’t be used with MBEDTLS_PLATFORM_TIME_ALT? Can/Should I comment out
> the #error? I tried that and the library compiles without errors, and
> the software using the library also compiles without errors, but I
> have not yet checked, if it actually works.
>
> Best regards,
>
> Ralf Huber
>
> KION Supply Chain Solutions
>
> Linde Material Handling GmbH,
> Sitz der Gesellschaft: Aschaffenburg, Registergericht: Aschaffenburg
> HRB9963, Ust-IdNr. DE814809128, Geschäftsführung: Andreas Krinninger
> (Vorsitzender), Dr. Karoline Jung-Senssfelder, Ulrike Just, Dr. Frank
> Schepp, Vorsitzende des Aufsichtsrats: Valeria Gargiulo
>
>