public inbox for linux-fscrypt@vger.kernel.org
 help / color / mirror / Atom feed
From: Jes Sorensen <jes.sorensen@gmail.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-fscrypt@vger.kernel.org, kernel-team@fb.com,
	Jes Sorensen <jsorensen@fb.com>
Subject: Re: [PATCH 4/9] Move hash algorithm code to shared library
Date: Wed, 22 Apr 2020 13:57:44 -0400	[thread overview]
Message-ID: <8b2dd7d7-4442-16e7-e251-8254551fa81b@gmail.com> (raw)
In-Reply-To: <20200322053802.GH111151@sol.localdomain>

On 3/22/20 1:38 AM, Eric Biggers wrote:
> On Thu, Mar 12, 2020 at 05:47:53PM -0400, Jes Sorensen wrote:
>> diff --git a/libfsverity.h b/libfsverity.h
>> +struct fsverity_hash_alg {
>> +	const char *name;
>> +	unsigned int digest_size;
>> +	unsigned int block_size;
>> +	uint16_t hash_num;
>> +	struct hash_ctx *(*create_ctx)(const struct fsverity_hash_alg *alg);
>> +};
>> +
> 
> It's still a bit weird to have struct fsverity_hash_alg as part of the library
> API, since the .create_ctx() member is for internal library use only.  We at
> least need to clearly comment this:
> 
> 	struct fsverity_hash_alg {
> 		const char *name;
> 		unsigned int digest_size;
> 		unsigned int block_size;
> 		uint16_t hash_num;
> 
> 		/* for library-internal use only */
> 		struct hash_ctx *(*create_ctx)(const struct fsverity_hash_alg *alg);
> 	};
> 
> But ideally there would be nothing library-internal in the API at all.

So I looked this over again, and came up with a solution which gets rid
of struct fsverity_hash_alg from the public API. To get around it I
extended the API like this:

<uint16_t> = libfsverity_find_alg_by_name(<char *name>)
<int>      = libfsverity_digest_size(<uint16_t alg_nr>)

In order to be able to print the algorithm name and list supported
algorithms, I introduced:

<char *>   = libfsverity_alg_name(<uint16_t alg_nr>)

Cheers,
Jes

  reply	other threads:[~2020-04-22 17:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 21:47 [PATCH v3 0/9] Split fsverity-utils into a shared library Jes Sorensen
2020-03-12 21:47 ` [PATCH 1/9] Build basic shared library framework Jes Sorensen
2020-03-22  5:23   ` Eric Biggers
2020-03-22  5:33   ` Eric Biggers
2020-04-21 21:00     ` Jes Sorensen
2020-03-12 21:47 ` [PATCH 2/9] Change compute_file_measurement() to take a file descriptor as argument Jes Sorensen
2020-03-12 21:47 ` [PATCH 3/9] Move fsverity_descriptor definition to libfsverity.h Jes Sorensen
2020-03-22  4:57   ` Eric Biggers
2020-04-21 16:07     ` Jes Sorensen
2020-04-21 16:16       ` Eric Biggers
2020-04-21 16:20         ` Jes Sorensen
2020-03-12 21:47 ` [PATCH 4/9] Move hash algorithm code to shared library Jes Sorensen
2020-03-22  5:38   ` Eric Biggers
2020-04-22 17:57     ` Jes Sorensen [this message]
2020-03-12 21:47 ` [PATCH 5/9] Create libfsverity_compute_digest() and adapt cmd_sign to use it Jes Sorensen
2020-03-22  5:40   ` Eric Biggers
2020-03-12 21:47 ` [PATCH 6/9] Introduce libfsverity_sign_digest() Jes Sorensen
2020-03-12 21:47 ` [PATCH 7/9] Validate input arguments to libfsverity_compute_digest() Jes Sorensen
2020-03-12 21:47 ` [PATCH 8/9] Validate input parameters for libfsverity_sign_digest() Jes Sorensen
2020-03-22  5:27   ` Eric Biggers
2020-03-12 21:47 ` [PATCH 9/9] Document API of libfsverity Jes Sorensen
2020-03-22  5:54   ` Eric Biggers
2020-03-22  5:05 ` [PATCH v3 0/9] Split fsverity-utils into a shared library Eric Biggers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8b2dd7d7-4442-16e7-e251-8254551fa81b@gmail.com \
    --to=jes.sorensen@gmail.com \
    --cc=ebiggers@kernel.org \
    --cc=jsorensen@fb.com \
    --cc=kernel-team@fb.com \
    --cc=linux-fscrypt@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox