From ce38fd56db52704b5bac447ca02ee88a323b5140 Mon Sep 17 00:00:00 2001 From: Soyoung Kim Date: Wed, 6 Mar 2013 10:19:10 +0900 Subject: [PATCH] Change encryption API. [Issue#] N/A [Problem] N/A [Cause] N/A [Solution] encryption API changed to using trust zone. So resource encryption task should be changed. [SCMRequest] this commit should be release with wrt-commons. Change-Id: I4b547b44df70dd7af7525d1cd1c8d17c931d9629 --- src/jobs/widget_install/task_encrypt_resource.cpp | 28 ++++++++--------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/jobs/widget_install/task_encrypt_resource.cpp b/src/jobs/widget_install/task_encrypt_resource.cpp index ae9cebb..98faa16 100644 --- a/src/jobs/widget_install/task_encrypt_resource.cpp +++ b/src/jobs/widget_install/task_encrypt_resource.cpp @@ -47,7 +47,7 @@ using namespace WrtDB; using namespace WRTEncryptor; namespace { -const std::size_t ENCRYPTION_CHUNK_MAX_SIZE = 1024; // bytes +const std::size_t ENCRYPTION_CHUNK_MAX_SIZE = 1008; // bytes std::set& getSupportedForEncryption() { @@ -173,8 +173,6 @@ void TaskEncryptResource::StepEncryptResource() { LogDebug("Step Encrypt resource"); m_resEnc = new ResourceEncryptor; - m_resEnc->CreateEncryptionKey(DPL::ToUTF8String(m_context. - widgetConfig.tzAppid)); EncryptDirectory(m_context.locations->getTemporaryRootDir()); m_context.job->UpdateProgress( @@ -269,24 +267,16 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName) do { bytesRead = readBytes(inChunk.get(), chunkSize, inFile.Get()); - if (chunkSize != bytesRead) - { - curBlockSize = m_resEnc->GetBlockSize(bytesRead); - outChunk.reset(new unsigned char[curBlockSize]); - } - else - { - if (maxBlockSize != curBlockSize) - { - curBlockSize = maxBlockSize; - outChunk.reset(new unsigned char[curBlockSize]); - } + if (0 != bytesRead) { + int decBufSize = m_resEnc->EncryptChunkByTrustZone(DPL::ToUTF8String( + m_context.widgetConfig.tzAppid), + inChunk.get(), bytesRead); + outChunk.reset(new unsigned char[decBufSize]); + m_resEnc->getEncStringByTrustZone(outChunk.get()); + + writeBytes(outChunk.get(), decBufSize, outFile.Get()); } - m_resEnc->EncryptChunk(inChunk.get(), outChunk.get(), bytesRead); - - writeBytes(outChunk.get(), curBlockSize, outFile.Get()); - } while (0 == std::feof(inFile.Get())); LogDebug("File encrypted successfully"); -- 2.7.4