bitlk: Fix unlocking bitlocker with multibyte utf8 characters

Fixes: #950

Co-authored-by: Thomas Lidén
This commit is contained in:
Vojtech Trefny
2025-07-29 11:32:00 +02:00
committed by Milan Broz
parent 6c7c8d36bb
commit 04d307d9c0
3 changed files with 21 additions and 1 deletions

View File

@@ -982,6 +982,7 @@ static int bitlk_kdf(const char *password,
struct crypt_hash *hd = NULL;
int len = 0;
char16_t *utf16Password = NULL;
size_t utf16Len = 0;
int i = 0;
int r = 0;
@@ -1007,7 +1008,8 @@ static int bitlk_kdf(const char *password,
if (r < 0)
goto out;
crypt_hash_write(hd, (char*)utf16Password, passwordLen * 2);
utf16Len = crypt_char16_strlen(utf16Password);
crypt_hash_write(hd, (char*)utf16Password, utf16Len * 2);
r = crypt_hash_final(hd, kdf.initial_sha256, len);
if (r < 0)
goto out;