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

Eric Biggers
2024-12-02T18:27:07Z

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@kernel.org>
> Cc: Eric Biggers <ebiggers@kernel.org>
> Cc: linux-crypto@vger.kernel.org

Acked-by: Eric Biggers <ebiggers@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