[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YBMcBPXrKswTyiMC@sol.localdomain>
Date: Thu, 28 Jan 2021 12:18:12 -0800
From: Eric Biggers <ebiggers@...nel.org>
To: Stephan Müller <smueller@...onox.de>
Cc: herbert@...dor.apana.org.au, Jarkko Sakkinen <jarkko@...nel.org>,
mathew.j.martineau@...ux.intel.com, dhowells@...hat.com,
linux-crypto@...r.kernel.org, linux-fscrypt@...r.kernel.org,
linux-kernel@...r.kernel.org, keyrings@...r.kernel.org,
simo@...hat.com
Subject: Re: [PATCH v2 6/7] fs: use HKDF implementation from kernel crypto API
On Sun, Jan 24, 2021 at 03:04:31PM +0100, Stephan Müller wrote:
> @@ -74,16 +57,14 @@ int fscrypt_init_hkdf(struct fscrypt_hkdf *hkdf, const u8 *master_key,
> return PTR_ERR(hmac_tfm);
> }
>
> - if (WARN_ON(crypto_shash_digestsize(hmac_tfm) != sizeof(prk))) {
> + if (WARN_ON(crypto_shash_digestsize(hmac_tfm) != HKDF_HASHLEN)) {
> err = -EINVAL;
> goto err_free_tfm;
> }
>
> - err = hkdf_extract(hmac_tfm, master_key, master_key_size, prk);
> - if (err)
> - goto err_free_tfm;
> -
> - err = crypto_shash_setkey(hmac_tfm, prk, sizeof(prk));
> + /* HKDF-Extract (RFC 5869 section 2.2), unsalted */
> + err = crypto_hkdf_extract(hmac_tfm, NULL, 0,
> + master_key, master_key_size);
> if (err)
> goto err_free_tfm;
>
> @@ -93,7 +74,6 @@ int fscrypt_init_hkdf(struct fscrypt_hkdf *hkdf, const u8 *master_key,
> err_free_tfm:
> crypto_free_shash(hmac_tfm);
> out:
> - memzero_explicit(prk, sizeof(prk));
> return err;
> }
The 'out' label isn't needed anymore. 'goto out' should be replaced with
'return 0'.
- Eric
Powered by blists - more mailing lists