Add to get passphrase string from config
[platform/core/connectivity/net-config.git] / src / wifi-key-encryption.c
index d57bce1..03b5da3 100755 (executable)
@@ -127,9 +127,9 @@ static int __netconfig_generate_aes_key()
 
 static void*  __netconfig_set_param_list_aes_gcm(ckmc_param_list_h param)
 {
-       ckmc_raw_buffer_s *iv_buf;
+       ckmc_raw_buffer_s *iv_buf = NULL;
        unsigned char rnd[RND_LENGTH];
-       ckmc_raw_buffer_s *aad_buf;
+       ckmc_raw_buffer_s *aad_buf = NULL;
        unsigned char aad[RND_LENGTH];
 
        err = ckmc_get_data(IV_ALIAS, NULL, &iv_buf);
@@ -205,6 +205,7 @@ gchar* _netconfig_encrypt_passphrase(const gchar *passphrase)
                        g_free(origin_value));
 
        if (__netconfig_set_param_list_aes_gcm(param) == NULL) {
+               ckmc_param_list_free(param);
                g_free(origin_value);
                return NULL;
        }
@@ -261,6 +262,7 @@ static gchar* _netconfig_decrypt_passphrase(const gchar *enc_data)
                        g_free(ehexstr));
 
        if (__netconfig_set_param_list_aes_gcm(param) == NULL) {
+               ckmc_param_list_free(param);
                g_free(ehexstr);
                return NULL;
        }
@@ -306,7 +308,7 @@ gboolean handle_encrypt_passphrase(Wifi *wifi, GDBusMethodInvocation *context, c
        if ((wifi == NULL) || (passphrase == NULL)) {
                ERR("Invalid parameter");
                netconfig_error_invalid_parameter(context);
-               return FALSE;
+               return TRUE;
        }
 
        enc_data = _netconfig_encrypt_passphrase(passphrase);