Re: [PATCH 4/9] Move hash algorithm code to shared library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [linux Cryptography]     [Asterisk App Development]     [PJ SIP]     [Gnu Gatekeeper]     [IETF Sipping]     [Info Cyrus]     [ALSA User]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite News]     [Deep Creek Hot Springs]     [Yosemite Campsites]     [ISDN Cause Codes]

  Powered by Linux