Removing encryption key after application uninstallation. 09/45109/3 accepted/tizen/mobile/20150811.014001 accepted/tizen/tv/20150811.014009 accepted/tizen/wearable/20150811.014019 submit/tizen/20150810.135518
authorPawel Sikorski <p.sikorski@samsung.com>
Fri, 31 Jul 2015 10:17:05 +0000 (12:17 +0200)
committerPawel Sikorski <p.sikorski@samsung.com>
Mon, 10 Aug 2015 10:38:54 +0000 (12:38 +0200)
During deinstallation, wae_remove_app_dek function is called
to remove encryption key from WAE module.
Note: there is no information, if given application is encrypted or
not. So the function is always called. If, WAE_ERROR_NO_KEY error is
returned, it can be assumed, that given application was not encrypted.

Change-Id: I9b7f54bde88ad012249f77784c46aa80c1097ff3

src/wgt/CMakeLists.txt
src/wgt/step/step_remove_encryption_data.cc [new file with mode: 0644]
src/wgt/step/step_remove_encryption_data.h [new file with mode: 0644]
src/wgt/wgt_backend.cc

index ce9e194..9b0d9ee 100644 (file)
@@ -5,6 +5,7 @@ SET(SRCS
   step/step_create_symbolic_link.cc
   step/step_encrypt_resources.cc
   step/step_parse.cc
+  step/step_remove_encryption_data.cc
   step/step_rds_parse.cc
   step/step_rds_modify.cc
   step/step_wgt_create_icons.cc
diff --git a/src/wgt/step/step_remove_encryption_data.cc b/src/wgt/step/step_remove_encryption_data.cc
new file mode 100644 (file)
index 0000000..24357f6
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "wgt/step/step_remove_encryption_data.h"
+
+#include <web_app_enc.h>
+
+#include "common/utils/logging.h"
+
+
+namespace wgt {
+namespace encrypt {
+
+common_installer::Step::Status StepRemoveEncryptionData::process() {
+  // 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());
+  if (WAE_ERROR_NONE == ret || WAE_ERROR_NO_KEY == ret) {
+    LOG(DEBUG) << "Encryption data removed (if existed)";
+    return common_installer::Step::Status::OK;
+  }
+
+  switch (ret) {
+  case WAE_ERROR_INVALID_PARAMETER:
+    LOG(ERROR) << "Error while removing encryption data: "
+                  "WAE_ERROR_INVALID_PARAMETER";
+    break;
+  case WAE_ERROR_PERMISSION_DENIED:
+    LOG(ERROR) << "Error while removing encryption data: "
+                  "WAE_ERROR_PERMISSION_DENIED";
+    break;
+  case WAE_ERROR_KEY_MANAGER:
+    LOG(ERROR) << "Error while removing encryption data: "
+                  "WAE_ERROR_KEY_MANAGER";
+    break;
+  case WAE_ERROR_UNKNOWN:
+    LOG(ERROR) << "Error while removing encryption data: "
+                  "WAE_ERROR_UNKNOWN";
+    break;
+  default:
+    LOG(ERROR) << "Error while removing encryption data: "
+                  "UNKNOWN";
+    break;
+  }
+  return common_installer::Step::Status::ERROR;
+}
+
+}  // namespace encrypt
+}  // namespace wgt
diff --git a/src/wgt/step/step_remove_encryption_data.h b/src/wgt/step/step_remove_encryption_data.h
new file mode 100644 (file)
index 0000000..8415cc2
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef WGT_STEP_STEP_REMOVE_ENCRYPTION_DATA_H_
+#define WGT_STEP_STEP_REMOVE_ENCRYPTION_DATA_H_
+
+#include "common/step/step.h"
+#include "common/utils/logging.h"
+
+namespace wgt {
+namespace encrypt {
+
+class StepRemoveEncryptionData : public common_installer::Step {
+ public:
+  using Step::Step;
+
+  Status process() override;
+  Status clean() override { return Status::OK; }
+  Status undo() override { return Status::OK; }
+  Status precheck() override { return Status::OK; }
+
+  SCOPE_LOG_TAG(RemoveEncryptionData)
+};
+}  // namespace encrypt
+}  // namespace wgt
+#endif  // WGT_STEP_STEP_REMOVE_ENCRYPTION_DATA_H_
index a3cb9c2..d07ec17 100644 (file)
@@ -32,6 +32,7 @@
 #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_remove_encryption_data.h"
 #include "wgt/step/step_rds_parse.h"
 #include "wgt/step/step_rds_modify.h"
 #include "wgt/step/step_wgt_create_icons.h"
@@ -101,6 +102,7 @@ int main(int argc, char** argv) {
       installer.AddStep<ci::filesystem::StepRemoveFiles>();
       installer.AddStep<ci::filesystem::StepRemoveIcons>();
       installer.AddStep<ci::security::StepRevokeSecurity>();
+      installer.AddStep<wgt::encrypt::StepRemoveEncryptionData>();
       break;
     }
     case ci::PkgMgrInterface::Type::Reinstall: {