remove dependency encryption library from wrt-commons
authorSoyoung Kim <sy037.kim@samsung.com>
Mon, 11 Mar 2013 10:23:58 +0000 (19:23 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Mon, 11 Mar 2013 10:42:11 +0000 (19:42 +0900)
[Issue#] N/A
[Problem] occur cyclic dependency
[Cause] wrt-commons has cyclic dependecy because of osp-appfw
[Solution] remove dependency.
[SCMRequest] N/A

Change-Id: I246913be3111c47aebc6204063c580331de99490

packaging/wrt.spec
src/view/webkit/bundles/CMakeLists.txt
src/view/webkit/bundles/wrt-wk2-bundle.cpp
src/view/webkit/bundles/wrt-wk2-bundle.h

index 5524af0..246767c 100644 (file)
@@ -44,6 +44,9 @@ BuildRequires:  pkgconfig(dpl-encryption)
 BuildRequires:  pkgconfig(wrt-popup-wrt-runner)
 BuildRequires:  pkgconfig(wrt-popup-ace-runner)
 BuildRequires:  pkgconfig(sysman)
+BuildRequires:  pkgconfig(osp-appfw)
+BuildRequires:  osp-appfw-internal-devel
+Requires: osp-appfw
 
 ## wrt-launchpad-daemon #######################################################
 BuildRequires:  pkgconfig(app-checker)
index beb0a14..2069856 100644 (file)
@@ -27,6 +27,7 @@ PKG_CHECK_MODULES(BUNDLES_DEP
     dpl-encryption
     ewebkit2
     vconf
+    osp-appfw
     REQUIRED
 )
 
@@ -56,6 +57,9 @@ TARGET_LINK_LIBRARIES(${TARGET_BUNDLES_LIB}
     ${PROF_LIB}
 )
 
+# for encryption
+TARGET_LINK_LIBRARIES(${TARGET_BUNDLES_LIB} -L/usr/lib/osp -losp-appfw)
+
 SET_TARGET_PROPERTIES(${TARGET_BUNDLES_LIB} PROPERTIES
     VERSION ${PROJECT_VERSION}
     SOVERSION ${PROJECT_API_VERSION})
index 05fc92d..055960b 100644 (file)
@@ -53,6 +53,8 @@
 #include <dpl/utils/mime_type_utils.h>
 #include <dpl/localization/LanguageTagsProvider.h>
 #include <dpl/event/main_event_dispatcher.h>
+#include <FBaseByteBuffer.h>
+#include <security/FSecCrypto_TrustZoneService.h>
 
 #include <wrt_plugin_module.h>
 #include <profiling_util.h>
@@ -99,7 +101,6 @@ Bundle::Bundle(WKBundleRef bundle) :
     m_theme(""),
     m_willRemoveContext(NULL),
     m_encrypted(false),
-    m_resDec(NULL),
     m_widgetType(WrtDB::APP_TYPE_UNKNOWN),
     m_initialized(false)
 {
@@ -862,21 +863,11 @@ std::string Bundle::DecryptResource(std::string resource, int size)
 
     struct stat buf;
     if (0 == stat(filePath.c_str(), &buf)) {
-        if (NULL == m_resDec) {
-            using namespace WrtDB;
-            m_resDec = new
-                WRTDecryptor::ResourceDecryptor(DPL::ToUTF8String(
-                                                    m_widgetTizenId));
-            WrtDB::WidgetDAOReadOnly(m_widgetTizenId).
-                getEncryptedFileList(m_encryptedFiles);
-        }
-
         const std::size_t fileSize = buf.st_size;
         const std::size_t readBufSize = (fileSize > FILE_BUF_MAX_SIZE
                 ? FILE_BUF_MAX_SIZE : fileSize);
 
         std::unique_ptr<unsigned char[]> inChunk(new unsigned char[readBufSize]);
-        std::unique_ptr<unsigned char[]> outChunk;
 
         FILE* fp = fopen(filePath.c_str(), "rb");
         if (NULL == fp) {
@@ -894,14 +885,14 @@ std::string Bundle::DecryptResource(std::string resource, int size)
 
             if (0 != readSize) {
                 LogDebug("resource is encrypted. decrypting....");
-                int decSize = m_resDec->DecryptChunkByTrustZone(
-                        DPL::ToUTF8String(m_widgetTizenId), inChunk.get(),
-                        readSize);
-                outChunk.reset(new unsigned char[decSize]);
-                m_resDec->getDecryptStringByTrustZone(outChunk.get());
+                using namespace Tizen::Base;
+                ByteBuffer *getBuffer =
+                    reinterpret_cast<ByteBuffer*>(DecryptChunkByTrustZone(inChunk.get(),
+                                readSize));
                 memcpy(DecryptedString.get() + (PLAIN_CHUNK_SIZE * count++),
-                        outChunk.get(),
+                        getBuffer->GetPointer(),
                         (readSize < PLAIN_CHUNK_SIZE ? readSize : PLAIN_CHUNK_SIZE));
+                getBuffer->Reset();
             }
 
         } while( 0 == std::feof(fp));
@@ -927,6 +918,31 @@ std::string Bundle::DecryptResource(std::string resource, int size)
     return std::string();
 }
 
+void *Bundle::DecryptChunkByTrustZone(const unsigned char *inBuffer,
+        int inBufSize)
+{
+    using namespace Tizen::Base;
+    std::string pkgid(DPL::ToUTF8String(m_widgetTizenId));
+
+    const byte *b_pkgid = reinterpret_cast<const byte*>(pkgid.c_str());
+    ByteBuffer appInfo;
+    appInfo.Construct(pkgid.length());
+    appInfo.SetArray(b_pkgid, 0, pkgid.length());
+    appInfo.Flip();
+
+    Tizen::Security::Crypto::_TrustZoneService* pInstance;
+    pInstance = Tizen::Security::Crypto::_TrustZoneService::GetInstance();
+
+    ByteBuffer pBuf;
+    pBuf.Construct(inBufSize);
+    const byte *pByte = reinterpret_cast<const byte*>(inBuffer);
+    pBuf.SetArray(pByte, 0, inBufSize);
+    pBuf.Flip();
+
+    ByteBuffer *getBuffer = pInstance->_TrustZoneService::DecryptN(appInfo, pBuf);
+    return reinterpret_cast<void*>(getBuffer);
+}
+
 void Bundle::requestSuspend()
 {
     LogDebug("Unregister callbacks");
index 9ff545c..bc9a45d 100644 (file)
@@ -29,7 +29,6 @@
 #include <WKPageLoadTypes.h>
 #include <WKBundlePage.h>
 #include <dpl/string.h>
-#include <dpl/encryption/resource_decryption.h>
 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
 
 extern "C" {
@@ -75,7 +74,6 @@ class Bundle
     std::set<JSGlobalContextRef> m_loadedContext;
     JSGlobalContextRef m_willRemoveContext;
     bool m_encrypted;
-    WRTDecryptor::ResourceDecryptor *m_resDec;
     WrtDB::EncryptedFileList m_encryptedFiles;
     WrtDB::WidgetType m_widgetType;
        bool m_initialized;
@@ -167,6 +165,8 @@ class Bundle
     void requestResume();
 
     void connectLoaderClientCallbacksToPage(WKBundlePageRef page);
+    void *DecryptChunkByTrustZone(const unsigned char *inBuffer,
+                                 int inBufSize);
 };
 
 #endif /* WRT_SRC_VIEW_WEBKIT2_WRT_WK2_BUNDLE_H_ */