From: Sungbae Yoo Date: Tue, 14 Feb 2017 11:33:32 +0000 (+0900) Subject: External: Fix bugs that decryption doesn't work properly by ui-app X-Git-Tag: submit/tizen/20170217.072251~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b364f41f6a079dde69189e0e06c9c079fe8de549;p=platform%2Fcore%2Fsecurity%2Fode.git External: Fix bugs that decryption doesn't work properly by ui-app Signed-off-by: Sungbae Yoo Change-Id: I23fed938dd87afb6363723dc54eb35cb53dd960a --- diff --git a/server/engine/encryption/ecryptfs-engine.cpp b/server/engine/encryption/ecryptfs-engine.cpp index 9eaef01..b7d2161 100644 --- a/server/engine/encryption/ecryptfs-engine.cpp +++ b/server/engine/encryption/ecryptfs-engine.cpp @@ -37,7 +37,7 @@ #define MEDIA_EXCLUSION_LIST "temp_video/Camera/DCIM:mp3|mpga|m4a|mp4|wav|amr|awb|wma|ogg|oga|aac|mka|flac|3gp|3ga|mid|midi|xmf|rtttl|rtx|ota|smf|spm|imy|mpeg|m4v|3gp|3gpp|3g2|3gpp2|wmv|asf|mkv|webm|ts|avi|jpg|jpeg|gif|png|bmp|wbmp|divx|flv|ac3|mov|tiff|f4v|mpeg3|voice" #define CIPHER_MODE "aes" -#define ENCRYPTION_TMP_DIR ".ecryptfs_encrypted" +#define ENCRYPTION_TMP_DIR ".ecryptfs_temp" #define ECRYPTFS_VERSION_MAJOR 0x00 @@ -353,8 +353,8 @@ void EcryptfsEngine::encrypt(const data &key, unsigned int options) if (tempDir.exists()) { tempDir.remove(true); } - tempDir.makeDirectory(); + if (!(options & OPTION_ONLY_NEW_FILE)) { copyInPlace(destination, destination, tempDir.getPath(), [](const std::string &file) { @@ -365,6 +365,8 @@ void EcryptfsEngine::encrypt(const data &key, unsigned int options) this->progress.update(current * 100 / totalSize); }); } + + tempDir.remove(true); } catch (runtime::Exception &e) { try { ecryptfsUmount(destination); @@ -390,6 +392,9 @@ void EcryptfsEngine::decrypt(const data &key, unsigned int options) runtime::File tempDir(source + "/" ENCRYPTION_TMP_DIR); runtime::File tempMountpoint(tempDir.getPath() + "/mount"); + if (tempDir.exists()) { + tempDir.remove(true); + } tempDir.makeDirectory(); tempMountpoint.makeDirectory(); diff --git a/tools/apps/ode/include/ode-password.h b/tools/apps/ode/include/ode-password.h index 7cf9b37..26599e7 100755 --- a/tools/apps/ode/include/ode-password.h +++ b/tools/apps/ode/include/ode-password.h @@ -36,6 +36,7 @@ enum { INSERT_SD_CARD, INTERNAL_ENCRYPT_PASSWORD, INTERNAL_DECRYPT_PASSWORD, + EXTERNAL_DECRYPT_PASSWORD, }; typedef struct { diff --git a/tools/apps/ode/src/ode-app-confirm.c b/tools/apps/ode/src/ode-app-confirm.c index f53ce26..d921a30 100755 --- a/tools/apps/ode/src/ode-app-confirm.c +++ b/tools/apps/ode/src/ode-app-confirm.c @@ -61,21 +61,19 @@ static void _confirm_next_btn_clicked_cb(void *data, Evas_Object *obj, void *eve break; case ENCRYPT_SD_CARD: dlog_print(DLOG_DEBUG, LOG_TAG, "encrypt sd card confrim"); - create_base_window(); - create_progress_view("Encrypting", "External"); ret = ode_external_encryption_encrypt(ad->entry_data, 0); if (ret != 0) { dlog_print(DLOG_DEBUG, LOG_TAG, "external encryption failed"); } + create_base_window(); + create_progress_view("Encrypting", "External"); break; case DECRYPT_SD_CARD: dlog_print(DLOG_DEBUG, LOG_TAG, "decrypt sd card confrim"); - create_base_window(); - create_progress_view("Decrypting", "External"); - ret = ode_external_encryption_decrypt(ad->entry_data); - if (ret != 0) { - dlog_print(DLOG_DEBUG, LOG_TAG, "external decryption failed"); - } + popup_data.parent = ad->base; + popup_data.popup = NULL; + popup_data.mode = EXTERNAL_DECRYPT_PASSWORD; + create_confirm_password_popup(&popup_data); break; } } diff --git a/tools/apps/ode/src/password/confirm-popup.c b/tools/apps/ode/src/password/confirm-popup.c index a40a362..3ed8537 100755 --- a/tools/apps/ode/src/password/confirm-popup.c +++ b/tools/apps/ode/src/password/confirm-popup.c @@ -121,7 +121,7 @@ static void confirm_password_popup_confirm_cb(void *data, Evas_Object *obj, void popup_data_s *popup_data = (popup_data_s *)data; /* for temporary start */ - if (popup_data->mode == INTERNAL_ENCRYPT_PASSWORD || popup_data->mode == INTERNAL_DECRYPT_PASSWORD) { + if (popup_data->mode == INTERNAL_ENCRYPT_PASSWORD || popup_data->mode == INTERNAL_DECRYPT_PASSWORD || popup_data->mode == EXTERNAL_DECRYPT_PASSWORD) { snprintf(popup_data->entry_data, PATH_MAX, "%s", elm_entry_entry_get(confirm_entry)); evas_object_del(popup_data->popup); password_result_callback(popup_data, "success"); diff --git a/tools/apps/ode/src/password/password.c b/tools/apps/ode/src/password/password.c index 38f19db..4ab13cb 100755 --- a/tools/apps/ode/src/password/password.c +++ b/tools/apps/ode/src/password/password.c @@ -128,6 +128,15 @@ void password_result_callback(popup_data_s *data, const char *result) return; } break; + case EXTERNAL_DECRYPT_PASSWORD: + ret = ode_external_encryption_decrypt(data->entry_data); + if (ret != 0) { + dlog_print(DLOG_DEBUG, LOG_TAG, "failed to decrypt internal storage"); + return; + } + create_base_window(); + create_progress_view("Decrypting", "External"); + break; /* for temporary end */ default: break;