Make DBX be included in build if the environment is set right.

Signed-off-by: Peter Jones <pjones@redhat.com>
Bump version to 0.4

Since I've finally merged in the "sections" branch, best to increment
the version number.

Signed-off-by: Peter Jones <pjones@redhat.com>
Fix some pointer casting issues.

This also fixes the size of an empty vendor_cert or dbx_cert.

Signed-off-by: Peter Jones <shim-owner@fedoraproject.org>
Don't print that fallback isn't found in should_use_fallback()

The call can simply fail if it isn't found - which will be the case on
removeable install media.

Signed-off-by: Peter Jones <pjones@redhat.com>
Don't print things on the screen by default when everything works.

There's no point to this text, and it generally confuses people.

Signed-off-by: Peter Jones <pjones@redhat.com>
Make SHIM_LOCK_GUID a first-class object with a symbol.

Right now the CA is checking if shim builds expose a particular version
of the shim protocol.  To do this, they're looking for SHIM_LOCK_GUID's
value in the resulting binary.

Currently, with SHIM_LOCK_GUID as a macro that gets assigned to local
variables, that means they have to compensate for mov instructions mixed
in with the actual value.  This is completely absurd, so promote it to a
first-class object with a symbol to make it both easy to find and
continuous.

Signed-off-by: Peter Jones <pjones@redhat.com>
Made TODO represent the present.

Signed-off-by: Peter Jones <pjones@redhat.com>
Update TODO with missing description.

Signed-off-by: Peter Jones <pjones@redhat.com>
Make vendor_cert/vendor_dbx actually replaceable by an external tool.

This moves them both to be computed at runtime from a pointer+offset
rather than just a pointer, so that their real address can be entirely
derived from the section they're in.

This means you can replace the whole .vendor_cert section with a new one
with certs that don't have the same size.
Harden shim against non-participating bootloaders.

It works like this: during startup of shim, we hook into the system's
ExitBootServices() and StartImage().  If the system's StartImage() is
called, we automatically unhook, because we're chainloading to something
the system can verify.

When shim's verify is called, we record what kind of certificate the
image was verified against.  If the call /succeeds/, we remove our
hooks.

If ExitBootServices() is called, we check how the bootloader verified
whatever it is loading.  If it was verified by its hash, we unhook
everything and call the system's EBS().  If it was verified by
certificate, we check if it has called shim_verify().  If it has, we
unhook everything and call the system's EBS()

If the bootloader has not verified anything, and is itself verified by
a certificate, we display a security violation warning and halt the
machine.
Include shim's vendor_cert in MokListRT

There needs to be some way to communicate to the kernel that it's a
trusted key, and since this mechanism already exists, it's by far the
easiest.

Signed-off-by: Peter Jones <pjones@redhat.com>