#include "openssl-util.h"
#include "os-util.h"
#include "path-util.h"
+#include "pcrextend-util.h"
#include "pidref.h"
#include "proc-cmdline.h"
#include "process-util.h"
DissectImageFlags flags,
PartitionPolicyFlags policy_flags) {
- bool check_signature;
- int r, k;
+ int r;
assert(cd);
assert(name);
assert(verity);
+ bool check_signature;
if (iovec_is_set(&verity->root_hash_sig) && FLAGS_SET(policy_flags, PARTITION_POLICY_SIGNED)) {
r = secure_getenv_bool("SYSTEMD_DISSECT_VERITY_SIGNATURE");
if (r < 0 && r != -ENXIO)
} else
check_signature = false;
+ bool measure_signature;
if (check_signature) {
+ int k;
+
/* First, if we have support for signed keys in the kernel, then try that first. */
r = sym_crypt_activate_by_signed_key(
cd,
CRYPT_ACTIVATE_READONLY);
if (r >= 0) {
log_debug("Verity activation via kernel signature logic worked.");
- return 0;
+ measure_signature = true;
+ goto done;
}
log_debug_errno(r, "Validation of dm-verity signature failed via the kernel, trying userspace validation instead: %m");
/* Otherwise let's see what signature-less activation results in. */
+ measure_signature = true;
+
} else if (!FLAGS_SET(policy_flags, PARTITION_POLICY_VERITY))
return log_debug_errno(SYNTHETIC_ERRNO(ERFKILL),
"No-signature activation of Verity volume not allowed by policy, refusing.");
+ else
+ measure_signature = false;
r = sym_crypt_activate_by_volume_key(
cd,
return log_debug_errno(r, "Activation of Verity via root hash failed: %m");
log_debug("Activation of Verity via root hash succeeded.");
+
+done:
+ (void) pcrextend_verity_now(
+ name,
+ &verity->root_hash,
+ measure_signature ? &verity->root_hash_sig : NULL);
return 0;
}