[Release] wrt-commons_0.2.88 submit/tizen_2.0/20121229.051323
authorJihoon Chung <jihoon.chung@samsung.com>
Sat, 29 Dec 2012 05:12:57 +0000 (14:12 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Sat, 29 Dec 2012 05:12:57 +0000 (14:12 +0900)
Change-Id: I75010545e0bd27a0d60296c87fba7a64a51c2169

13 files changed:
build/encryption/CMakeLists.txt
build/encryption/libs/libcal.a [new file with mode: 0755]
build/encryption/libs/libcal.arm.a [new file with mode: 0755]
build/encryption/libs/libcal.i586.a [new file with mode: 0755]
debian/changelog
modules/encryption/include/dpl/encryption/resource_decryption.h
modules/encryption/include/dpl/encryption/resource_encryption.h
modules/encryption/src/resource_decryption.cpp
modules/encryption/src/resource_encryption.cpp
modules/widget_dao/CMakeLists.txt
modules/widget_dao/include/dpl/wrt-dao-ro/global_config.h
modules/widget_dao/include/dpl/wrt-dao-ro/vconf_config.h [new file with mode: 0644]
packaging/wrt-commons.spec

index 710ada6242beb930ccec059df76b87565a5fd54d..bf38caed371b467c520e1256872d1ce7dbca3f54 100644 (file)
@@ -54,6 +54,8 @@ TARGET_LINK_LIBRARIES(${TARGET_DPL_ENCRYPTION}
     ${TARGET_DPL_EFL}
 )
 
+TARGET_LINK_LIBRARIES(${TARGET_DPL_ENCRYPTION} -L./libs -lcal)
+
 # Target library properties
 SET_TARGET_PROPERTIES(${TARGET_DPL_ENCRYPTION} PROPERTIES
     SOVERSION ${API_VERSION}
diff --git a/build/encryption/libs/libcal.a b/build/encryption/libs/libcal.a
new file mode 100755 (executable)
index 0000000..8400c5f
Binary files /dev/null and b/build/encryption/libs/libcal.a differ
diff --git a/build/encryption/libs/libcal.arm.a b/build/encryption/libs/libcal.arm.a
new file mode 100755 (executable)
index 0000000..f1d622b
Binary files /dev/null and b/build/encryption/libs/libcal.arm.a differ
diff --git a/build/encryption/libs/libcal.i586.a b/build/encryption/libs/libcal.i586.a
new file mode 100755 (executable)
index 0000000..b02e413
Binary files /dev/null and b/build/encryption/libs/libcal.i586.a differ
index 5fd642df03c405e5f166bbfafb4d1f312d9d470e..52e2fd1323d2569055a86418b6ec4b0c7faf054e 100644 (file)
@@ -1,3 +1,21 @@
+wrt-commons (0.2.88) unstable; urgency=low
+
+  * Add path builder for vconf key
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.88
+
+ -- Jihoon Chung <jihoon.chung@samsung.com>  Sat, 29 Dec 2012 14:02:18 +0900
+
+wrt-commons (0.2.87) unstable; urgency=low
+
+  * changed to get encryption/decryption key from device unique key
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.87
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Fri, 28 Dec 2012 20:47:21 +0900
+
 wrt-commons (0.2.86) unstable; urgency=low
 
   * Revert "Modify get encryption/decryption key from device unique key"
index c22b1d21f691339ca372fc4a43826cd4f7056045..2a39eb197d034f0fecac03739b1affc7c9036953 100644 (file)
@@ -28,8 +28,9 @@
 #include <openssl/sha.h>
 #include <dpl/exception.h>
 
-namespace WRTDecryptor{
+extern char** calculate(char*pappId, int idLen, int keyLen);
 
+namespace WRTDecryptor{
 class ResourceDecryptor
 {
   public:
@@ -50,7 +51,7 @@ class ResourceDecryptor
 
   private:
       AES_KEY* GetDecryptionKey();
-      AES_KEY *m_decKey;
+      AES_KEY m_decKey;
 
 };
 } //namespace WRTDecryptor 
index ffc82c212e275a8d3e49147408f860e12aa74e3f..6f57a93235f27ed03c1c5c982d13df14227c3f1e 100644 (file)
@@ -28,8 +28,9 @@
 #include <openssl/sha.h>
 #include <dpl/exception.h>
 
-namespace WRTEncryptor{
+extern char** calculate(char*pappId, int idLen, int keyLen);
 
+namespace WRTEncryptor{
 class ResourceEncryptor
 {
   public:
index db45f81e67b0e9622d3430480f100a57b347f934..9e8b39f806f578f7de245df1e6274dd1d2aed67b 100644 (file)
 #include <dpl/exception.h>
 
 namespace {
-inline std::string GetDefaultEncryptKeyPath() {
-    return "/opt/share/widget/data/";
-}
+#define BITS_SIZE 128
+#define KEY_SIZE 16
 }
 namespace WRTDecryptor{
-ResourceDecryptor::ResourceDecryptor() :
-    m_decKey(NULL)
+ResourceDecryptor::ResourceDecryptor()
 {
     LogDebug("Started Decryption");
 }
 
-ResourceDecryptor::ResourceDecryptor(std::string userKey) :
-    m_decKey(NULL)
+ResourceDecryptor::ResourceDecryptor(std::string userKey) 
 {
     LogDebug("Finished Decryption");
     SetDecryptionKey(userKey);
@@ -48,47 +45,39 @@ ResourceDecryptor::ResourceDecryptor(std::string userKey) :
 
 ResourceDecryptor::~ResourceDecryptor()
 {
-    delete m_decKey;
 }
 
 void ResourceDecryptor::SetDecryptionKey(std::string userKey)
 {
-    /* TODO : get key from secure storage */
-    std::string keyPath = GetDefaultEncryptKeyPath() + userKey + "_dec";
-    LogDebug("Description Key path : " << keyPath);
-
-    FILE* fp = fopen(keyPath.c_str(), "rb");
-    if (fp == NULL) {
-        ThrowMsg(ResourceDecryptor::Exception::GetDecKeyFailed,
-                "Failed to get decryption key");
+    if (userKey.empty()) {
+        return;
     }
 
-    m_decKey = new AES_KEY;
-    size_t resultSize =fread(m_decKey, 1, sizeof(AES_KEY),fp);
-    if (resultSize!= sizeof(AES_KEY))
-        ThrowMsg(ResourceDecryptor::Exception::GetDecKeyFailed,
-                "Failed to get AES key");
+    char **duk = calculate(const_cast<char*>(userKey.c_str()), userKey.size(), KEY_SIZE);
+    unsigned char *key = reinterpret_cast<unsigned char*>(*duk);
 
-    fclose(fp);
+    if ( 0 > AES_set_decrypt_key(key, BITS_SIZE, &m_decKey)) {
+        ThrowMsg(ResourceDecryptor::Exception::GetDecKeyFailed,
+                "Failed to create decryption key");
+    }
 }
 
 AES_KEY* ResourceDecryptor::GetDecryptionKey()
 {
-    return m_decKey;
+    return &m_decKey;
 }
 
 void ResourceDecryptor::GetDecryptedChunk(unsigned char*
         inBuf, unsigned char* decBuf, size_t inBufSize)
 {
     Assert(decBuf);
-    Assert(m_decKey);
-    if (decBuf == NULL || m_decKey == NULL) {
+    if (decBuf == NULL) {
         ThrowMsg(ResourceDecryptor::Exception::EncryptionFailed,
                 "Failed to Get Decryption Chunk");
     }
     unsigned char ivec[16] = {0, };
 
-    AES_cbc_encrypt(inBuf, decBuf, inBufSize, m_decKey, ivec, AES_DECRYPT);
+    AES_cbc_encrypt(inBuf, decBuf, inBufSize, &m_decKey, ivec, AES_DECRYPT);
     LogDebug("Success decryption");
 }
 
index e89940ece6d94eac616308aadd217e5b51ccfa3b..a2387051c094a58ae04953ef9ab53e535c2f9d6d 100644 (file)
 
 namespace {
 #define BITS_SIZE 128
-const char* ENCRYPTION_FILE = "_enc";
-const char* DECRYPTION_FILE = "_dec";
-
-inline std::string GetDefaultEncryptKeyPath() {
-    return "/opt/share/widget/data";
-}
+#define KEY_SIZE 16
 }
 namespace WRTEncryptor{
 ResourceEncryptor::ResourceEncryptor()
@@ -59,44 +54,13 @@ void ResourceEncryptor::CreateEncryptionKey(std::string userKey)
         return;
     }
 
-    AES_KEY decKey;
-    const unsigned char* key = reinterpret_cast<unsigned char*>(
-                                    const_cast<char*>(userKey.c_str()));
+    char **duk = calculate(const_cast<char*>(userKey.c_str()), userKey.size(), KEY_SIZE);
+    unsigned char *key = reinterpret_cast<unsigned char*>(*duk);
 
     if ( 0 > AES_set_encrypt_key(key, BITS_SIZE, &m_encKey)) {
         ThrowMsg(ResourceEncryptor::Exception::CreateEncKeyFailed,
                 "Failed to create encryption key");
     }
-    if ( 0 > AES_set_decrypt_key(key, BITS_SIZE, &decKey)) {
-        ThrowMsg(ResourceEncryptor::Exception::CreateDecKeyFailed,
-                "Failed to create decryption key");
-    }
-
-    std::string encPath, decPath;
-
-    encPath = GetDefaultEncryptKeyPath() + "/" + userKey + ENCRYPTION_FILE;
-    decPath = GetDefaultEncryptKeyPath() + "/" + userKey + DECRYPTION_FILE;
-
-    /* TODO : save keys to secure storage */
-    LogDebug("Encryption Key path " << encPath);
-    LogDebug("Decryption Key path " << decPath);
-
-    FILE* encFp = fopen(encPath.c_str(), "wb");
-    if (encFp == NULL) {
-        ThrowMsg(ResourceEncryptor::Exception::CreateEncKeyFileFailed,
-                "Failed to save encryption key");
-    }
-    fwrite(&m_encKey, 1, sizeof(m_encKey), encFp);
-    fclose(encFp);
-
-    FILE* decFp = fopen(decPath.c_str(), "wb");
-    if (decFp == NULL) {
-        ThrowMsg(ResourceEncryptor::Exception::CreateDecKeyFileFailed,
-                "Failed to save decryption key");
-    }
-
-    fwrite(&decKey, 1, sizeof(decKey), decFp);
-    fclose(decFp);
     LogDebug("Success to create ecryption and decryption key");
 }
 
index fca9cbaf22b39aef6644e85aa76b7132ed0e4399..cf1034fcb3228e92806f8462a159c2f41f20c125 100644 (file)
@@ -126,11 +126,12 @@ INSTALL(FILES
     include/dpl/wrt-dao-ro/plugin_dao_read_only.h
     include/dpl/wrt-dao-ro/property_dao_read_only.h
     include/dpl/wrt-dao-ro/widget_config.h
+    include/dpl/wrt-dao-ro/vconf_config.h
     include/dpl/wrt-dao-ro/widget_dao_read_only.h
     include/dpl/wrt-dao-ro/wrt_db_types.h
     include/dpl/wrt-dao-ro/WrtDatabase.h
     DESTINATION include/dpl-efl/dpl/wrt-dao-ro
-       )
+    )
 
 INSTALL(FILES
     include/dpl/wrt-dao-rw/feature_dao.h
index 27212143ec15f80f87579262236200f7af70d3ff..87bf9d623bc7ede63af9bdef1cc84b6b41b80718 100644 (file)
@@ -284,6 +284,37 @@ inline const char* GetTempInstallInfoPath()
 {
     return "/opt/share/widget/temp_info";
 }
+
+inline const char* GetVconfKeyPrefixPath()
+{
+    return "file/private";
+}
+
+inline const char* GetVconfKeyPopupUsagePath()
+{
+    return "/popup_usage";
+}
+
+inline const char* GetVconfKeyGeolocationUsagePath()
+{
+    return "/geolocation_usage";
+}
+
+inline const char* GetVconfKeyWebNotificationUsagePath()
+{
+    return "/web_notification_usage";
+}
+
+inline const char* GetVconfKeyWebDatabaseUsagePath()
+{
+    return "/web_database_usage";
+}
+
+inline const char* GetVconfKeyFilesystemUsagePath()
+{
+    return "/filesystem_usage";
+}
+
 } // namespace GlobalConfig
 } // namespace WrtDB
 
diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/vconf_config.h b/modules/widget_dao/include/dpl/wrt-dao-ro/vconf_config.h
new file mode 100644 (file)
index 0000000..4a3c2cb
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/**
+ * @file    vconf_config.h
+ * @author  Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for vconf key config.
+ */
+#ifndef SRC_DOMAIN_VCONF_CONFIG_H
+#define SRC_DOMAIN_VCONF_CONFIG_H
+
+#include <string>
+#include <dpl/string.h>
+
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/path_builder.h>
+
+namespace WrtDB {
+namespace VconfConfig {
+inline std::string GetVconfKeyRootPath(DPL::String pkgName)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(pkgName))
+               .GetFullPath();
+}
+
+inline std::string GetVconfKeyPopupUsage(DPL::String pkgName)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(pkgName))
+               .Concat(GlobalConfig::GetVconfKeyPopupUsagePath())
+               .GetFullPath();
+}
+
+inline std::string GetVconfKeyGeolocationUsage(DPL::String pkgName)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(pkgName))
+               .Concat(GlobalConfig::GetVconfKeyGeolocationUsagePath())
+               .GetFullPath();
+}
+
+inline std::string GetVconfKeyWebNotificationUsage(DPL::String pkgName)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(pkgName))
+               .Concat(GlobalConfig::GetVconfKeyWebNotificationUsagePath())
+               .GetFullPath();
+}
+
+inline std::string GetVconfKeyWebDatabaseUsage(DPL::String pkgName)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(pkgName))
+               .Concat(GlobalConfig::GetVconfKeyWebDatabaseUsagePath())
+               .GetFullPath();
+}
+
+inline std::string GetVconfKeyFilesystemUsage(DPL::String pkgName)
+{
+    return PathBuilder()
+               .Append(GlobalConfig::GetVconfKeyPrefixPath())
+               .Append(DPL::ToUTF8String(pkgName))
+               .Concat(GlobalConfig::GetVconfKeyFilesystemUsagePath())
+               .GetFullPath();
+}
+
+} // namespace VconfConfig
+} // namespace WrtDB
+
+#endif
index 0751d22904e7c84ec746303ced86331191752b1c..a1ca79e6295f1bee127418b0faca11eafb0b122f 100644 (file)
@@ -1,7 +1,7 @@
-#git:framework/web/wrt-commons wrt-commons 0.2.86
+#git:framework/web/wrt-commons wrt-commons 0.2.88
 Name:       wrt-commons
 Summary:    Wrt common library
-Version:    0.2.86
+Version:    0.2.88
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
@@ -44,6 +44,13 @@ Wrt common library development headers
 %endif
 
 %build
+
+%ifarch %{ix86}
+cp build/encryption/libs/libcal.i586.a build/encryption/libs/libcal.a
+%else
+cp build/encryption/libs/libcal.arm.a build/encryption/libs/libcal.a
+%endif
+
 export LDFLAGS+="-Wl,--rpath=%{_libdir} -Wl,--hash-style=both -Wl,--as-needed"
 
 cmake . -DVERSION=%{version} \