WebApp encryption step alignement to libwebapenc library API change 54/46054/3
authorPawel Sikorski <p.sikorski@samsung.com>
Thu, 13 Aug 2015 10:41:12 +0000 (12:41 +0200)
committerPawel Sikorski <p.sikorski@samsung.com>
Thu, 20 Aug 2015 08:46:20 +0000 (01:46 -0700)
Requires: https://review.tizen.org/gerrit/#/c/46007/

Change-Id: I718f11f597cf8a7bd9916607864920582ca21cd7

src/wgt/step/step_encrypt_resources.cc
src/wgt/step/step_remove_encryption_data.cc
src/wgt/wgt_installer.cc

index 1511431..a1ca7c5 100644 (file)
@@ -56,6 +56,7 @@ common_installer::Step::Status StepEncryptResources::process() {
     LOG(DEBUG) << "no encryption";
     return common_installer::Step::Status::OK;
   }
+  LOG(DEBUG) << "Encrypting";
 
   if (!Encrypt(input_)) {
     LOG(ERROR) << "Error during encryption";
@@ -125,11 +126,14 @@ bool StepEncryptResources::EncryptFile(const bf::path &src) {
   unsigned char* encrypted_data = nullptr;
   size_t enc_data_len = 0;
   // TODO(p.sikorski) check if it is Preloaded
-  int is_preloaded = 0;
+  wae_app_type_e enc_type =
+      context_->uid.get() == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) ?
+          WAE_DOWNLOADED_GLOBAL_APP : WAE_DOWNLOADED_NORMAL_APP;
+
 
   int ret = wae_encrypt_web_application(
               context_->pkgid.get().c_str(),
-              is_preloaded,
+              enc_type,
               reinterpret_cast<const unsigned char*>(input_buffer),
               length,
               &encrypted_data,
index 24357f6..d22f0de 100644 (file)
@@ -13,10 +13,14 @@ namespace wgt {
 namespace encrypt {
 
 common_installer::Step::Status StepRemoveEncryptionData::process() {
+  wae_app_type_e enc_type =
+      context_->uid.get() == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) ?
+          WAE_DOWNLOADED_GLOBAL_APP : WAE_DOWNLOADED_NORMAL_APP;
+
   // There is no check, if application was encrypted or not
   // (it is not saved anywhere in tizen manifest)
   // so, if WAE_ERROR_NO_KEY error, then application was not encrypted
-  int ret = wae_remove_app_dek(context_->pkgid.get().c_str());
+  int ret = wae_remove_app_dek(context_->pkgid.get().c_str(), enc_type);
   if (WAE_ERROR_NONE == ret || WAE_ERROR_NO_KEY == ret) {
     LOG(DEBUG) << "Encryption data removed (if existed)";
     return common_installer::Step::Status::OK;
index 9b75632..7609060 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "wgt/step/step_create_symbolic_link.h"
 #include "wgt/step/step_check_settings_level.h"
+#include "wgt/step/step_encrypt_resources.h"
 #include "wgt/step/step_parse.h"
 #include "wgt/step/step_parse_recovery.h"
 #include "wgt/step/step_remove_encryption_data.h"
@@ -63,6 +64,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<wgt::parse::StepParse>(true);
       AddStep<ci::security::StepCheckSignature>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
+      AddStep<wgt::encrypt::StepEncryptResources>();
       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
       AddStep<ci::filesystem::StepCopy>();
       AddStep<wgt::filesystem::StepWgtCreateStorageDirectories>();