mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 06:30:33 +01:00
libnm/crypto: minor cleanup confusing comment in crypto_decrypt_openssl_private_key_data()
the comment and code made it sound like parse_old_openssl_key_file() would set @key_type if the parsing was only done partially. That is not the case, @key_type is only set, if parsing was successful. Adjust the code. While at it, don't require the caller to initialize @out_key_type. It's just an enum, if we care to always set it, just do it.
This commit is contained in:
parent
c366c155f1
commit
3536960eb7
1 changed files with 4 additions and 6 deletions
|
|
@ -487,17 +487,13 @@ crypto_decrypt_openssl_private_key_data (const guint8 *data,
|
|||
char *cipher = NULL;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
if (out_key_type)
|
||||
g_return_val_if_fail (*out_key_type == NM_CRYPTO_KEY_TYPE_UNKNOWN, NULL);
|
||||
|
||||
NM_SET_OUT (out_key_type, NM_CRYPTO_KEY_TYPE_UNKNOWN);
|
||||
|
||||
if (!crypto_init (error))
|
||||
return NULL;
|
||||
|
||||
parsed = parse_old_openssl_key_file (data, data_len, &key_type, &cipher, &iv, NULL);
|
||||
/* return the key type even if decryption failed */
|
||||
if (out_key_type)
|
||||
*out_key_type = key_type;
|
||||
|
||||
if (!parsed) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERROR_INVALID_DATA,
|
||||
|
|
@ -505,6 +501,8 @@ crypto_decrypt_openssl_private_key_data (const guint8 *data,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
NM_SET_OUT (out_key_type, key_type);
|
||||
|
||||
if (password) {
|
||||
if (!cipher || !iv) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue