aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-06-18 12:26:59 -0700
committerEric Biggers <ebiggers@google.com>2019-06-18 12:26:59 -0700
commitb09ba7eb3fa537d4d1184ea0aecd2c57ac121cce (patch)
treed49bcc426d0b4a7a0e0056b450e30836ea85aefa
parent7c8901f260056998fe3606835fee957e66c0fa80 (diff)
downloadfsverity-utils-b09ba7eb3fa537d4d1184ea0aecd2c57ac121cce.tar.gz
cmd_sign: support empty files
I'm planning to make the kernel support fs-verity on empty files, so support them in the 'fsverity sign' command too. Signed-off-by: Eric Biggers <ebiggers@google.com>
-rw-r--r--cmd_sign.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/cmd_sign.c b/cmd_sign.c
index f7bd21f..0c1dfe7 100644
--- a/cmd_sign.c
+++ b/cmd_sign.c
@@ -479,11 +479,6 @@ static bool compute_file_measurement(const char *filename,
if (!get_file_size(&file, &file_size))
goto out;
- if (file_size <= 0) {
- error_msg("File must be nonempty!");
- goto out;
- }
-
memset(&desc, 0, sizeof(desc));
desc.version = 1;
desc.hash_algorithm = hash_alg - fsverity_hash_algs;
@@ -503,7 +498,9 @@ static bool compute_file_measurement(const char *filename,
desc.data_size = cpu_to_le64(file_size);
- if (!compute_root_hash(&file, file_size, hash, block_size, salt,
+ /* Root hash of empty file is all 0's */
+ if (file_size != 0 &&
+ !compute_root_hash(&file, file_size, hash, block_size, salt,
salt_size, desc.root_hash))
goto out;