[PATCH 01/10] crypto,fs: Separate out hkdf_extract() and hkdf_expand()

Eric Biggers ebiggers at kernel.org
Mon Dec 2 10:27:05 PST 2024


On Mon, Dec 02, 2024 at 03:29:50PM +0100, Hannes Reinecke wrote:
> Separate out the HKDF functions into a separate module to
> to make them available to other callers.
> And add a testsuite to the module with test vectors
> from RFC 5869 (and additional vectors for SHA384 and SHA512)
> to ensure the integrity of the algorithm.
> 
> Signed-off-by: Hannes Reinecke <hare at kernel.org>
> Cc: Eric Biggers <ebiggers at kernel.org>
> Cc: linux-crypto at vger.kernel.org

Acked-by: Eric Biggers <ebiggers at kernel.org>

> +int hkdf_expand(struct crypto_shash *hmac_tfm,
> +		const u8 *info, unsigned int infolen,
> +		u8 *okm, unsigned int okmlen)
> +{
> +	SHASH_DESC_ON_STACK(desc, hmac_tfm);
> +	unsigned int i, hashlen = crypto_shash_digestsize(hmac_tfm);
> +	int err;
> +	const u8 *prev = NULL;
> +	u8 counter = 1;
> +	u8 tmp[HASH_MAX_DIGESTSIZE] = {};

Zero-initializing tmp is not necessary.

- Eric



More information about the Linux-nvme mailing list