blob: e00892ea8671ec53e4ec813d830f33222b94e89d [file] [log] [blame] [view]
Serge Bazanski2dc42802024-06-04 14:30:19 +00001swtpm enhancements
2==================
3
4Metropolis uses [swtpm](https://github.com/stefanberger/swtpm) for emulating a
5TPM device when running tests in qemu, eg. end-to-end-tests.
6
7swtpm consists of a runtime emulator (`swtpm`) which runs against a state
8directory and exposes TPM functionality over the socket; and of tooling
9designed to create said state directory (`swtpm_setup`, `swtpm_localca`, etc).
10
11Getting the former to be built with Bazel is generally trivial, as it mostly
12depends on libraries we are already building (glib, openssl/boringssll, etc).
13However, the tooling is another story: it depends heavily on GnuTLS, both as a
14library to link against and as a runtime tool (`certtool`). We already have one
15C implementation of cryptographic primitives in `//third_party` (boringssl),
16dragging another one in would be shameful.
17
18The tooling is also not a single C binary, but a handful of different ones that
19call eachother based on the requested functionality (presumably as a way to
20implement modularity to allow creating swtpm secrets using a HSM, etc).
21
22This subdirectory contains bits and pieces that allow us to use the
23aforementioned tooling without depending on GnuTLS. This is done by patching
24some tools to rip out GnuTLS support, and by replacing other with native Go
25reimplementations.
26
27certtool
28--------
29
30This is a minimal GnuTLS certtool reimplementation in Go. It's used by `swtpm_localca` to generate TLS certificates. An
31alternative to this would be to rewrite `swtpm_localca` entirely to Go, but that seems like a bit too much effort for
32now.