</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>tpm2-measure-nvpcr=</option></term>
+
+ <listitem><para>Takes a boolean argument, or an NvPCR name as argument. May be used to enable
+ automatic measurement of the volume name and Verity root hash, as well as the serials and issuers of
+ the certificates used to generate the provided signatures (if any) will be measured. Passing false
+ disables the mechanism. Passing true enables measurement into the <literal>verity</literal> NvPCR. If
+ any other string is specified this selects the NvPCR to measure into by name.</para>
+
+ <xi:include href="version-info.xml" xpointer="v260"/></listitem>
+ </varlistentry>
+
</variablelist>
<para>At early boot and when the system manager configuration is
#include "main-func.h"
#include "parse-util.h"
#include "path-util.h"
+#include "pcrextend-util.h"
#include "pretty-print.h"
#include "string-util.h"
#include "strv.h"
+#include "tpm2-util.h"
#include "verbs.h"
static char *arg_hash = NULL; /* the hash algorithm */
static void *arg_root_hash_signature = NULL;
static size_t arg_root_hash_signature_size = 0;
static bool arg_root_hash_signature_auto = false;
+static char *arg_tpm2_measure_nvpcr = NULL;
STATIC_DESTRUCTOR_REGISTER(arg_hash, freep);
STATIC_DESTRUCTOR_REGISTER(arg_salt, freep);
STATIC_DESTRUCTOR_REGISTER(arg_uuid, freep);
STATIC_DESTRUCTOR_REGISTER(arg_fec_what, freep);
STATIC_DESTRUCTOR_REGISTER(arg_root_hash_signature, freep);
+STATIC_DESTRUCTOR_REGISTER(arg_tpm2_measure_nvpcr, freep);
static int help(void) {
_cleanup_free_ char *link = NULL;
for (;;) {
_cleanup_free_ char *word = NULL;
- char *val;
+ const char *val;
r = extract_first_word(&options, &word, ",", EXTRACT_DONT_COALESCE_SEPARATORS | EXTRACT_UNESCAPE_SEPARATORS);
if (r < 0)
if (r < 0)
return r;
+ } else if ((val = startswith(word, "tpm2-measure-nvpcr="))) {
+ r = isempty(val) ? 0 : parse_boolean(val);
+ if (r == 0) {
+ arg_tpm2_measure_nvpcr = mfree(arg_tpm2_measure_nvpcr);
+ return 0;
+ }
+ if (r > 0)
+ val = "verity";
+ else if (!tpm2_nvpcr_name_is_valid(val)) {
+ log_warning("Invalid NvPCR name, ignoring: %s", word);
+ return 0;
+ }
+
+ if (free_and_strdup(&arg_tpm2_measure_nvpcr, val) < 0)
+ return log_oom();
} else
log_warning("Encountered unknown option '%s', ignoring.", word);
}
if (r < 0)
return log_error_errno(r, "Failed to set up verity device '%s': %m", volume);
+ (void) pcrextend_verity_now(
+ volume,
+ &IOVEC_MAKE(rh, rh_size),
+ &IOVEC_MAKE(arg_root_hash_signature, arg_root_hash_signature_size));
+
return 0;
}