lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YalFa3eBR/8tp0AP@sol.localdomain>
Date:   Thu, 2 Dec 2021 14:15:07 -0800
From:   Eric Biggers <ebiggers@...nel.org>
To:     Mimi Zohar <zohar@...ux.ibm.com>
Cc:     linux-integrity@...r.kernel.org, linux-fscrypt@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 1/5] fs-verity: define a function to return the
 integrity protected file digest

On Thu, Dec 02, 2021 at 04:55:03PM -0500, Mimi Zohar wrote:
> +
> +/**
> + * fsverity_collect_digest() - get a verity file's digest
> + * @inode: inode to get digest of
> + * @digest: (out) pointer to the digest
> + * @alg: (out) pointer to the hash algorithm enumeration
> + *
> + * Return the file hash algorithm and digest of an fsverity protected file.
> + *
> + * Return: 0 on success, -errno on failure
> + */
> +int fsverity_collect_digest(struct inode *inode,
> +			    u8 digest[FS_VERITY_MAX_DIGEST_SIZE],
> +			    enum hash_algo *alg)

I'd still prefer that this be named fsverity_get_digest(), but this is fine too.

> +{
> +	const struct fsverity_info *vi;
> +	const struct fsverity_hash_alg *hash_alg;
> +	int i;
> +
> +	vi = fsverity_get_info(inode);
> +	if (!vi)
> +		return -ENODATA; /* not a verity file */
> +
> +	hash_alg = vi->tree_params.hash_alg;
> +	memset(digest, 0, FS_VERITY_MAX_DIGEST_SIZE);
> +	*alg = HASH_ALGO__LAST;
> +
> +	/* convert hash algorithm to hash_algo_name */
> +	for (i = 0; i < HASH_ALGO__LAST; i++) {
> +		pr_debug("name %s hash_algo_name[%d] %s\n",
> +			  hash_alg->name, i, hash_algo_name[i]);
> +
> +		if (!strcmp(hash_alg->name, hash_algo_name[i])) {
> +			*alg = i;
> +			break;
> +		}
> +	}

How about using match_string() here?

> +	pr_debug("file digest:%s %*phN\n", hash_algo_name[*alg],
> +		  hash_digest_size[*alg], digest);

Other log messages in fs/verity/ use the format alg:hash.  How about using
"file_digest %s:%*phN\n" as the format string here?

- Eric

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ