From: Soyoung Kim Date: Tue, 21 May 2013 12:30:54 +0000 (+0900) Subject: Add encryption for preload web app X-Git-Tag: submit/tizen_2.2/20130716.180435~1^2~122 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2deb3462d61a89b2a8dc8df321d1e052cea0bc1e;p=framework%2Fweb%2Fwrt-installer.git Add encryption for preload web app [Issue#] N/A [Problem] Can't install web app is required encryption during preload. [Cause] there is no encryption api for preload web app. [Solution] Add encryption api using master key. [SCMRequest] this package have to release with ss-client and ss-server. Change-Id: Id05cd77cf3657526ee0f13286ef6bc179b2f6840 --- diff --git a/src/jobs/widget_install/task_encrypt_resource.cpp b/src/jobs/widget_install/task_encrypt_resource.cpp index c96d1a2..4e8a49b 100644 --- a/src/jobs/widget_install/task_encrypt_resource.cpp +++ b/src/jobs/widget_install/task_encrypt_resource.cpp @@ -51,7 +51,6 @@ using namespace WrtDB; namespace { const std::size_t ENCRYPTION_CHUNK_MAX_SIZE = 8192; // bytes const std::size_t ENCRYPTION_DEC_CHUNK_SIZE = 4; // bytes -static bool initWebApp = false; std::set& getSupportedForEncryption() { @@ -162,6 +161,18 @@ void writeBytes(unsigned char* buffer, std::size_t count, FILE* stream) } while ((bytesWritten != bytesToWrite) && (EINTR == errno)); } +int ssmEncrypt(InstallMode::RootPath rootPath, std::string pkgId, const char* + inChunk, int inBytes, char** outChunk, int *outBytes) +{ + if (rootPath == InstallMode::RootPath::RO) { + return ssm_encrypt_preloaded_application(inChunk, inBytes, + outChunk, outBytes); + } else { + return ssm_encrypt(pkgId.c_str(), pkgId.length(), + inChunk, inBytes, + outChunk, outBytes); + } +} } namespace Jobs { @@ -265,7 +276,8 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName) std::unique_ptr inChunk(new unsigned char[chunkSize]); std::size_t bytesRead = 0; - std::string appid = DPL::ToUTF8String(m_context.widgetConfig.tzAppid); + /* TODO : pkgId should change to appId after wrt-client label changed. */ + std::string pkgId = DPL::ToUTF8String(m_context.widgetConfig.tzPkgid); do { @@ -273,7 +285,7 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName) if (0 != bytesRead) { int outDecSize = 0; char *outChunk = NULL; - if (0 != ssm_encrypt(appid.c_str(), appid.length(), + if (0 != ssmEncrypt(m_context.mode.rootPath, pkgId, (char*)inChunk.get(), (int)bytesRead, &outChunk, &outDecSize)) { ThrowMsg(Exceptions::EncryptionFailed,