From: Eric Biggers <ebiggers@kernel.org>
To: luca.boccassi@gmail.com
Cc: linux-fscrypt@vger.kernel.org
Subject: Re: [fsverity-utils PATCH v4] Add digest sub command
Date: Mon, 26 Oct 2020 11:58:06 -0700 [thread overview]
Message-ID: <20201026185806.GK858@sol.localdomain> (raw)
In-Reply-To: <20201026181729.3322756-1-luca.boccassi@gmail.com>
On Mon, Oct 26, 2020 at 06:17:29PM +0000, luca.boccassi@gmail.com wrote:
> +/* Compute a file's fs-verity measurement, then print it in hex format. */
> +int fsverity_cmd_digest(const struct fsverity_command *cmd,
> + int argc, char *argv[])
Since it can be more than one file now:
/* Compute the fs-verity measurement of the given file(s), for offline signing */
> + for (int i = 0; i < argc; i++) {
> + struct filedes file = { .fd = -1 };
> + struct fsverity_signed_digest *d = NULL;
> + struct libfsverity_digest *digest = NULL;
> + char digest_hex[FS_VERITY_MAX_DIGEST_SIZE * 2 + sizeof(struct fsverity_signed_digest) * 2 + 1];
> +
> + if (!open_file(&file, argv[i], O_RDONLY, 0))
> + goto out_err;
> +
> + if (!get_file_size(&file, &tree_params.file_size))
> + goto out_err;
'file' doesn't get closed on error. Making it back to the outer scope would fix
that.
> + if (compact)
> + printf("%s\n", digest_hex);
> + else
> + printf("%s:%s %s\n",
> + libfsverity_get_hash_name(tree_params.hash_algorithm),
> + digest_hex, argv[i]);
I don't think the hash algorithm should be printed in the
'!compact && for_builtin_sig' case, since it's already included in the struct
that gets hex-encoded. I.e.
else if (for_builtin_sig)
printf("%s %s\n", digest_hex, argv[i]);
> diff --git a/programs/fsverity.c b/programs/fsverity.c
> index 95f6964..c7c4f75 100644
> --- a/programs/fsverity.c
> +++ b/programs/fsverity.c
> @@ -21,6 +21,14 @@ static const struct fsverity_command {
> const char *usage_str;
> } fsverity_commands[] = {
> {
> + .name = "digest",
> + .func = fsverity_cmd_digest,
> + .short_desc = "Compute and print hex-encoded fs-verity digest of a file, for offline signing",
Likewise, since this can now accept multiple files:
"Compute the fs-verity measurement of the given file(s), for offline signing"
(I don't think that "printed as hex" needs to be explicitly mentioned here.)
- Eric
next prev parent reply other threads:[~2020-10-26 18:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-22 17:21 [fsverity-utils PATCH] Add digest sub command luca.boccassi
2020-10-24 4:23 ` Eric Biggers
2020-10-26 11:49 ` Luca Boccassi
2020-10-26 11:40 ` [fsverity-utils PATCH v2] " luca.boccassi
2020-10-26 17:48 ` Eric Biggers
2020-10-26 18:12 ` Luca Boccassi
2020-10-26 18:11 ` [fsverity-utils PATCH v3] " luca.boccassi
2020-10-26 18:17 ` [fsverity-utils PATCH v4] " luca.boccassi
2020-10-26 18:58 ` Eric Biggers [this message]
2020-10-26 19:21 ` Luca Boccassi
2020-10-26 19:18 ` [fsverity-utils PATCH v5] " luca.boccassi
2020-10-26 20:36 ` Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201026185806.GK858@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=luca.boccassi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox