blob: 6aab10fceaf2584beffcea04bc4c20c0531b276d [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
Serge Bazanski551a8192024-06-04 14:32:11 +000027swtpm_cert
28----------
29
30This is a reimplementation of swtpm_cert in Go. The upstream swtpm_cert is implemented in C and has a hard dependency on
31GnuTLS and libtasn1. Rewriting it in Go and using plain stdlib functions seems like the correct solution here (the
32alternative being either bringing in GnuTLS/libtasn1 into `third_party`, or rewriting swtpm_cert to use
33OpenSSL/BoringSSL).
34
Serge Bazanski2dc42802024-06-04 14:30:19 +000035certtool
36--------
37
38This is a minimal GnuTLS certtool reimplementation in Go. It's used by `swtpm_localca` to generate TLS certificates. An
39alternative to this would be to rewrite `swtpm_localca` entirely to Go, but that seems like a bit too much effort for
40now.