Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Eric Biggers <ebiggers@google.com>
Tested-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Eric Biggers and committed by
Richard Weinberger
738fadaa 861deac3

+2 -17
+2 -17
fs/ubifs/auth.c
··· 507 507 */ 508 508 int ubifs_hmac_wkm(struct ubifs_info *c, u8 *hmac) 509 509 { 510 - SHASH_DESC_ON_STACK(shash, c->hmac_tfm); 511 - int err; 512 510 const char well_known_message[] = "UBIFS"; 513 511 514 512 if (!ubifs_authenticated(c)) 515 513 return 0; 516 514 517 - shash->tfm = c->hmac_tfm; 518 - 519 - err = crypto_shash_init(shash); 520 - if (err) 521 - return err; 522 - 523 - err = crypto_shash_update(shash, well_known_message, 524 - sizeof(well_known_message) - 1); 525 - if (err < 0) 526 - return err; 527 - 528 - err = crypto_shash_final(shash, hmac); 529 - if (err) 530 - return err; 531 - return 0; 515 + return crypto_shash_tfm_digest(c->hmac_tfm, well_known_message, 516 + sizeof(well_known_message) - 1, hmac); 532 517 } 533 518 534 519 /*