# Re: \[PATCH 1/4\] fs-verity: define a function to return the integrity protected file digest

- From: Eric Biggers \<ebiggers@kernel.org\>
- Date: 2021-11-30 02:19:23 
- List: linux-integrity
- Page: https://ratatoskr.run/linux-integrity/2021/11/1590760
- Thread: https://ratatoskr.run/linux-integrity/2021/11/1589774/t.md

```text
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@linux.ibm.com>
> ---
>  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
> + * @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
```
