pkcs12: Treat empty string and no password differently

When deriving the PKCS#12 key, the empty string should result in a
non-zero length Unicode string (two bytes for the 0 terminator).
This commit is contained in:
Tobias Brunner 2023-10-18 17:11:51 +02:00
parent 7bb6aed5ab
commit ad804fa036

View File

@ -157,7 +157,7 @@ bool pkcs12_derive_key(hash_algorithm_t hash, chunk_t password, chunk_t salt,
bool success;
int i;
if (password.len)
if (password.ptr)
{ /* convert the password to UTF-16BE (without BOM) with 0 terminator */
unicode = chunk_alloca(password.len * 2 + 2);
for (i = 0; i < password.len; i++)