mirror of
https://git.code.sf.net/p/linux-ima/ima-evm-utils
synced 2025-07-01 05:11:13 +02:00
Verify an fs-verity file digest based signature
ima-evm-utils does not attempt to calculate or even read the fs-verity file hash, but can verify the fs-verity signature based on the fsverity file hash, both contained in the measurement list record. Example: evmctl ima_measurement --key <DER encoded public key> \ --verify-sig /sys/kernel/security/ima/binary_runtime_measurements Modify 'sig' argument of verify_hash() to be the full xattr in order to differentiate signatures types. Note: Kernel commit b1aaab22e263 ("ima: pass full xattr with the signature") added the 'type' to signature_v2_hdr struct, which hasn't been reflected here. (todo) Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
This commit is contained in:
11
src/evmctl.c
11
src/evmctl.c
@ -918,7 +918,7 @@ static int verify_evm(const char *file)
|
||||
return mdlen;
|
||||
assert(mdlen <= sizeof(hash));
|
||||
|
||||
return verify_hash(file, hash, mdlen, sig + 1, len - 1);
|
||||
return verify_hash(file, hash, mdlen, sig, len);
|
||||
}
|
||||
|
||||
static int cmd_verify_evm(struct command *cmd)
|
||||
@ -1583,7 +1583,8 @@ void ima_ng_show(struct template_entry *entry)
|
||||
fieldp += field_len;
|
||||
total_len -= field_len;
|
||||
|
||||
if (!strcmp(entry->name, "ima-sig")) {
|
||||
if (!strcmp(entry->name, "ima-sig") ||
|
||||
!strcmp(entry->name, "ima-sigv2")) {
|
||||
/* get signature */
|
||||
field_len = *(uint32_t *)fieldp;
|
||||
fieldp += sizeof(field_len);
|
||||
@ -1629,11 +1630,17 @@ void ima_ng_show(struct template_entry *entry)
|
||||
log_info(" ");
|
||||
log_dump(sig, sig_len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Either verify the signature against the hash contained in
|
||||
* the measurement list or calculate the hash.
|
||||
*/
|
||||
if (verify_list_sig)
|
||||
err = ima_verify_signature(path, sig, sig_len,
|
||||
digest, digest_len);
|
||||
else
|
||||
err = ima_verify_signature(path, sig, sig_len, NULL, 0);
|
||||
|
||||
if (!err && imaevm_params.verbose > LOG_INFO)
|
||||
log_info("%s: verification is OK\n", path);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user