Skip to content

Commit

Permalink
fscrypt: use crypto_shash_tfm_digest()
Browse files Browse the repository at this point in the history
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: Eric Biggers <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
ebiggers authored and herbertx committed May 8, 2020
1 parent 96a5aa7 commit 3e185a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
7 changes: 1 addition & 6 deletions fs/crypto/fname.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,8 @@ static int fscrypt_do_sha256(const u8 *data, unsigned int data_len, u8 *result)
tfm = prev_tfm;
}
}
{
SHASH_DESC_ON_STACK(desc, tfm);

desc->tfm = tfm;

return crypto_shash_digest(desc, data, data_len, result);
}
return crypto_shash_tfm_digest(tfm, data, data_len, result);
}

static inline bool fscrypt_is_dot_dotdot(const struct qstr *str)
Expand Down
6 changes: 1 addition & 5 deletions fs/crypto/hkdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,13 @@ static int hkdf_extract(struct crypto_shash *hmac_tfm, const u8 *ikm,
unsigned int ikmlen, u8 prk[HKDF_HASHLEN])
{
static const u8 default_salt[HKDF_HASHLEN];
SHASH_DESC_ON_STACK(desc, hmac_tfm);
int err;

err = crypto_shash_setkey(hmac_tfm, default_salt, HKDF_HASHLEN);
if (err)
return err;

desc->tfm = hmac_tfm;
err = crypto_shash_digest(desc, ikm, ikmlen, prk);
shash_desc_zero(desc);
return err;
return crypto_shash_tfm_digest(hmac_tfm, ikm, ikmlen, prk);
}

/*
Expand Down

0 comments on commit 3e185a5

Please sign in to comment.