fsverity: simplify fsverity_get_digest()
authorEric Biggers <ebiggers@google.com>
Tue, 29 Nov 2022 04:51:39 +0000 (20:51 -0800)
committerEric Biggers <ebiggers@google.com>
Wed, 30 Nov 2022 05:07:41 +0000 (21:07 -0800)
commita4bbf53d88c728da9ff6c316b1e4ded63a8f3940
tree0462f2ab83d7d9e8fe49c98a6625baf62135bcf7
parent98dc08bae6780bb950b5c0cdefeb662b22482655
fsverity: simplify fsverity_get_digest()

Instead of looking up the algorithm by name in hash_algo_name[] to get
its hash_algo ID, just store the hash_algo ID in the fsverity_hash_alg
struct.  Verify at boot time that every fsverity_hash_alg has a valid
hash_algo ID with matching digest size.

Remove an unnecessary memset() of the whole digest array to 0 before the
digest is copied into it.

Finally, remove the pr_debug statement.  There is already a pr_debug for
the fsverity digest when the file is opened.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Link: https://lore.kernel.org/r/20221129045139.69803-1-ebiggers@kernel.org
fs/verity/fsverity_private.h
fs/verity/hash_algs.c
fs/verity/measure.c