Commit 738fadaa authored by Eric Biggers's avatar Eric Biggers Committed by Richard Weinberger

ubifs: use crypto_shash_tfm_digest() in ubifs_hmac_wkm()

Simplify ubifs_hmac_wkm() by using crypto_shash_tfm_digest() instead of
an alloc+init+update+final sequence.  This should also improve
performance.
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Tested-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 861deac3
......@@ -507,28 +507,13 @@ int __ubifs_shash_copy_state(const struct ubifs_info *c, struct shash_desc *src,
*/
int ubifs_hmac_wkm(struct ubifs_info *c, u8 *hmac)
{
SHASH_DESC_ON_STACK(shash, c->hmac_tfm);
int err;
const char well_known_message[] = "UBIFS";
if (!ubifs_authenticated(c))
return 0;
shash->tfm = c->hmac_tfm;
err = crypto_shash_init(shash);
if (err)
return err;
err = crypto_shash_update(shash, well_known_message,
sizeof(well_known_message) - 1);
if (err < 0)
return err;
err = crypto_shash_final(shash, hmac);
if (err)
return err;
return 0;
return crypto_shash_tfm_digest(c->hmac_tfm, well_known_message,
sizeof(well_known_message) - 1, hmac);
}
/*
......
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