Commit 3e185a56 authored by Eric Biggers's avatar Eric Biggers Committed by Herbert Xu

fscrypt: use crypto_shash_tfm_digest()

Instead of manually allocating a 'struct shash_desc' on the stack and
calling crypto_shash_digest(), switch to using the new helper function
crypto_shash_tfm_digest() which does this for us.
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 96a5aa72
...@@ -83,13 +83,8 @@ static int fscrypt_do_sha256(const u8 *data, unsigned int data_len, u8 *result) ...@@ -83,13 +83,8 @@ static int fscrypt_do_sha256(const u8 *data, unsigned int data_len, u8 *result)
tfm = prev_tfm; tfm = prev_tfm;
} }
} }
{
SHASH_DESC_ON_STACK(desc, tfm);
desc->tfm = tfm; return crypto_shash_tfm_digest(tfm, data, data_len, result);
return crypto_shash_digest(desc, data, data_len, result);
}
} }
static inline bool fscrypt_is_dot_dotdot(const struct qstr *str) static inline bool fscrypt_is_dot_dotdot(const struct qstr *str)
......
...@@ -44,17 +44,13 @@ static int hkdf_extract(struct crypto_shash *hmac_tfm, const u8 *ikm, ...@@ -44,17 +44,13 @@ static int hkdf_extract(struct crypto_shash *hmac_tfm, const u8 *ikm,
unsigned int ikmlen, u8 prk[HKDF_HASHLEN]) unsigned int ikmlen, u8 prk[HKDF_HASHLEN])
{ {
static const u8 default_salt[HKDF_HASHLEN]; static const u8 default_salt[HKDF_HASHLEN];
SHASH_DESC_ON_STACK(desc, hmac_tfm);
int err; int err;
err = crypto_shash_setkey(hmac_tfm, default_salt, HKDF_HASHLEN); err = crypto_shash_setkey(hmac_tfm, default_salt, HKDF_HASHLEN);
if (err) if (err)
return err; return err;
desc->tfm = hmac_tfm; return crypto_shash_tfm_digest(hmac_tfm, ikm, ikmlen, prk);
err = crypto_shash_digest(desc, ikm, ikmlen, prk);
shash_desc_zero(desc);
return err;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment