Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

101.21. mbedtls-3.6.7

Mbed TLS: a small TLS and cryptography library, the 3.6 long-term line

Version 3.6.7, release 1
Shelf crypto — Cryptographic libraries, PKCS#11, smartcards and TPM
Phase 41_system (System), 329 of 1047 in build order
Licence Apache-2.0 OR GPL-2.0-or-later
Homepage https://www.trustedfirmware.org/projects/mbed-tls/
Build time 1.7 SBU
Installed size 3.5 MiB in 131 files
Recipe ports/core/crypto/mbedtls/kpkgbuild

About

Mbed TLS is a small TLS and cryptography library, written to be embedded. KDOS carries it for the programs written against it rather than against OpenSSL or GnuTLS: obs-studio uses it for its streaming outputs’ TLS, librist for RIST’s encryption, and imhex for its hashing and cryptography. The recipe stays on the long-term support line its series key names; see Filtering for what the key does. The port installs the shared libraries libmbedcrypto, libmbedx509 and libmbedtls, the headers, their pkg-config files and the CMake package.

Sources

Dependencies

Depends on: cmake, ninja.

Required by (3): imhex, librist, obs-studio.

Patches

build.sh applies these; kpkg applies nothing by itself.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install mbedtls'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/crypto/mbedtls.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/crypto/mbedtls
echo 'a7e8bcbec0e6f761b4af24f25677626b35f762f68eef79c08677a363212d11f6  mbedtls-3.6.7.tar.bz2' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/mbedtls
SRC=$SRC_ROOT/mbedtls-3.6.7
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf mbedtls-3.6.7.tar.bz2 -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers series and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

patch -p1 -i "$PORT_SRC/threading-pthread.patch"

mkdir -p build && cd build
cmake .. -G Ninja \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DCMAKE_INSTALL_LIBDIR=lib \
	-DUSE_SHARED_MBEDTLS_LIBRARY=ON \
	-DUSE_STATIC_MBEDTLS_LIBRARY=OFF \
	-DGEN_FILES=OFF \
	-DENABLE_PROGRAMS=OFF \
	-DENABLE_TESTING=OFF \
	-DMBEDTLS_FATAL_WARNINGS=OFF
ninja
DESTDIR=$PKG ninja install

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/mbedtls, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf mbedtls-3.6.7-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/mbedtls, and runs the triggers its paths call for.

Contents

Installed libraries: libeverest.a, libmbedcrypto.so, libmbedtls.so, libmbedx509.so, libp256m.a.

Installed directories: /usr/include/everest, /usr/include/mbedtls, /usr/include/psa, /usr/lib/cmake/MbedTLS, /usr/share/licenses/mbedtls.

Short descriptions

mbedcrypto.pc Mbed TLS is a C library that implements cryptographic primitives, X.509 certificate manipulation and the SSL/TLS and DTLS protocols. Its small code footprint makes it suitable for embedded systems.
mbedtls.pc Mbed TLS is a C library that implements cryptographic primitives, X.509 certificate manipulation and the SSL/TLS and DTLS protocols. Its small code footprint makes it suitable for embedded systems.
mbedx509.pc Mbed TLS is a C library that implements cryptographic primitives, X.509 certificate manipulation and the SSL/TLS and DTLS protocols. Its small code footprint makes it suitable for embedded systems.

Notes

Threading is set in the installed configuration header, never with a -D on the compiler’s command line. MBEDTLS_THREADING_C adds a mutex to the RSA context and to the contexts of the random number generators, the entropy source and the SSL cookie, ticket and session-cache modules, structures that consumers allocate themselves, so a consumer compiled without the define would disagree with the library about their layout. With it in mbedtls_config.h, every program that includes Mbed TLS’s headers sees the same value the library was built with.