mbedtls icon indicating copy to clipboard operation
mbedtls copied to clipboard

Split fopen and opendir platform requirements

Open gilles-peskine-arm opened this issue 2 years ago • 0 comments

MBEDTLS_FS_IO is documented as “Enable functions that use the filesystem.”. More precisely, it means that the platform has:

  • some basic functions from stdio.h: fopen(), fclose(), fread(), fwrite(), ftell(), fseek(), remove(), rename() (and more? printf and fprintf are required separately).
  • Either the trio of opendir(), readdir() and closedir(); or their Windows equivalent.

There are platforms that have files but not directories, or that have directories but not opendir() and friends (Window is one, for which we have special-case support).

The dir functions should actually probably be a separate compile-time option (not that the prospect of another compile-time option fills me with joy) to accommodate low-end platforms that have files with an stdio interface, but not directories.

opendir is used in only one place: mbedtls_x509_crt_parse_path. It definitely makes sense to build Mbed TLS with X.509 support but not mbedtls_x509_crt_parse_path. Plenty of embedded applications have a single root CA and so only need parse_file(), not parse_path().

gilles-peskine-arm avatar Aug 01 '22 09:08 gilles-peskine-arm