Hi Mimi,
On 11/29/2021 6:19 PM, Eric Biggers wrote:
Generally looks fine. A few nits below:
On Mon, Nov 29, 2021 at 12:00:54PM -0500, Mimi Zohar wrote:
Define a function named fsverity_measure() to return the verity file digest
and the associated hash algorithm (enum hash_algo).
Signed-off-by: Mimi Zohar <zohar@xxxxxxxxxxxxx>
---
fs/verity/fsverity_private.h | 6 -----
fs/verity/measure.c | 49 ++++++++++++++++++++++++++++++++++++
include/linux/fsverity.h | 17 +++++++++++++
3 files changed, 66 insertions(+), 6 deletions(-)
diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h
index a7920434bae5..54c5f0993541 100644
--- a/fs/verity/fsverity_private.h
+++ b/fs/verity/fsverity_private.h
@@ -26,12 +26,6 @@ struct ahash_request;
*/
#define FS_VERITY_MAX_LEVELS 8
-/*
- * Largest digest size among all hash algorithms supported by fs-verity.
- * Currently assumed to be <= size of fsverity_descriptor::root_hash.
- */
-#define FS_VERITY_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE
The include of sha2.h should be removed from this file.
+/**
+ * fsverity_measure() - get a verity file's digest
nit: The function name seems to suggest it is measuring the fs-verity
file's digest. Since it is reading the file's digest:
fsverity_read_digest() or fsverity_read_measure()?
-lakshmi
+ * @inode: inode to get digest of
+ * @digest: pointer to the digest
+ * @alg: pointer to the hash algorithm enumeration
It should be made clear that @digest and @alg are output, for example:
* @digest: (out) pointer to the digest
* @alg: (out) pointer to the hash algorithm enumeration
+ * Return the file hash algorithm, digest size, and digest of an fsverity
+ * protected file.
The digest size is implied, not returned.
+
+ if (!strcmp(hash_alg->name, hash_algo_name[i])) {
As the kernel test robot pointed out, this creates a dependency on
CRYPTO_HASH_INFO. So FS_VERITY will need to select CRYPTO_HASH_INFO.
- Eric