mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
bitlk: Fix unlocking bitlocker with multibyte utf8 characters
Fixes: #950 Co-authored-by: Thomas Lidén
This commit is contained in:
committed by
Milan Broz
parent
6c7c8d36bb
commit
04d307d9c0
@@ -982,6 +982,7 @@ static int bitlk_kdf(const char *password,
|
|||||||
struct crypt_hash *hd = NULL;
|
struct crypt_hash *hd = NULL;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
char16_t *utf16Password = NULL;
|
char16_t *utf16Password = NULL;
|
||||||
|
size_t utf16Len = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
@@ -1007,7 +1008,8 @@ static int bitlk_kdf(const char *password,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto out;
|
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);
|
r = crypt_hash_final(hd, kdf.initial_sha256, len);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ int crypt_base64_decode(char **out, size_t *out_length, const char *in, size_t i
|
|||||||
/* UTF8/16 */
|
/* UTF8/16 */
|
||||||
int crypt_utf16_to_utf8(char **out, const char16_t *s, size_t length /* bytes! */);
|
int crypt_utf16_to_utf8(char **out, const char16_t *s, size_t length /* bytes! */);
|
||||||
int crypt_utf8_to_utf16(char16_t **out, const char *s, size_t length);
|
int crypt_utf8_to_utf16(char16_t **out, const char *s, size_t length);
|
||||||
|
size_t crypt_char16_strlen(const char16_t *s);
|
||||||
|
|
||||||
/* Block ciphers */
|
/* Block ciphers */
|
||||||
int crypt_cipher_ivsize(const char *name, const char *mode);
|
int crypt_cipher_ivsize(const char *name, const char *mode);
|
||||||
|
|||||||
@@ -274,3 +274,20 @@ int crypt_utf8_to_utf16(char16_t **out, const char *s, size_t length)
|
|||||||
*p = 0;
|
*p = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* crypt_char16_strlen()
|
||||||
|
* @s: string to get length of
|
||||||
|
*
|
||||||
|
* Returns: number of 16-bit words in the string
|
||||||
|
*/
|
||||||
|
size_t crypt_char16_strlen(const char16_t *s) {
|
||||||
|
size_t n = 0;
|
||||||
|
|
||||||
|
assert(s);
|
||||||
|
|
||||||
|
while (*s != 0)
|
||||||
|
n++, s++;
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user