]> git.ipfire.org Git - thirdparty/grub.git/commit
lib/pbkdf2: Optimize PBKDF2 by reusing HMAC handle
authorGary Lin <glin@suse.com>
Thu, 14 Aug 2025 06:32:42 +0000 (14:32 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 23 Oct 2025 17:14:59 +0000 (19:14 +0200)
commita122e02623caaca4cc22a4e885da92784a70a88b
treec53ca70b358ca98bd2332bdc4db7118b3a648ae3
parent961e38b2b03c50a50859dbc484559b9b848e8d84
lib/pbkdf2: Optimize PBKDF2 by reusing HMAC handle

The previous PBKDF2 implementation used grub_crypto_hmac_buffer() which
allocates and frees an HMAC handle on every call. This approach caused
significant performance overhead slowing down the boot process considerably.

This commit refactors the PBKDF2 code to use the new HMAC functions
allowing the HMAC handle and its buffers to be allocated once and reused
across multiple operations. This change significantly reduces disk
unlocking time.

In a QEMU/OVMF test environment this patch reduced the time to unlock
a LUKS2 (*) partition from approximately 15 seconds to 4 seconds.

  (*) PBKDF2 SHA256 with 3454944 iterations.

Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/lib/pbkdf2.c