return;
}
- DPL::ScopedFClose inFile(openFile(fileName, "r"));
- DPL::ScopedFClose outFile(openFile(encFile, "w"));
+ // If update installed preload web, should skip encryption.
+ if (!(m_context.mode.rootPath == InstallMode::RootPath::RO &&
+ m_context.mode.installTime == InstallMode::InstallTime::PRELOAD
+ && m_context.mode.extension == InstallMode::ExtensionType::DIR)) {
- const std::size_t chunkSize = (fileSize > ENCRYPTION_CHUNK_MAX_SIZE
- ? ENCRYPTION_CHUNK_MAX_SIZE : fileSize);
+ DPL::ScopedFClose inFile(openFile(fileName, "r"));
+ DPL::ScopedFClose outFile(openFile(encFile, "w"));
- std::unique_ptr<unsigned char[]> inChunk(new unsigned char[chunkSize]);
- std::size_t bytesRead = 0;
- /* TODO : pkgId should change to appId after wrt-client label changed. */
- std::string pkgId = DPL::ToUTF8String(m_context.widgetConfig.tzPkgid);
+ const std::size_t chunkSize = (fileSize > ENCRYPTION_CHUNK_MAX_SIZE
+ ? ENCRYPTION_CHUNK_MAX_SIZE : fileSize);
- do
- {
- bytesRead = readBytes(inChunk.get(), chunkSize, inFile.Get());
- if (0 != bytesRead) {
- int outDecSize = 0;
- char *outChunk = NULL;
- if (0 != ssmEncrypt(m_context.mode.rootPath, pkgId,
- (char*)inChunk.get(), (int)bytesRead,
- &outChunk, &outDecSize)) {
- ThrowMsg(Exceptions::EncryptionFailed,
- "Encryption Failed using TrustZone");
- }
-
- std::stringstream toString;
- toString << outDecSize;
+ std::unique_ptr<unsigned char[]> inChunk(new unsigned char[chunkSize]);
+ std::size_t bytesRead = 0;
+ /* TODO : pkgId should change to appId after wrt-client label changed. */
+ std::string pkgId = DPL::ToUTF8String(m_context.widgetConfig.tzPkgid);
- writeBytes((unsigned char*)toString.str().c_str(),
- sizeof(int), outFile.Get());
- writeBytes((unsigned char*)outChunk, outDecSize, outFile.Get());
- delete outChunk;
- }
- inChunk.reset(new unsigned char[chunkSize]);
+ do
+ {
+ bytesRead = readBytes(inChunk.get(), chunkSize, inFile.Get());
+ if (0 != bytesRead) {
+ int outDecSize = 0;
+ char *outChunk = NULL;
+ if (0 != ssmEncrypt(m_context.mode.rootPath, pkgId,
+ (char*)inChunk.get(), (int)bytesRead,
+ &outChunk, &outDecSize)) {
+ ThrowMsg(Exceptions::EncryptionFailed,
+ "Encryption Failed using TrustZone");
+ }
+
+ std::stringstream toString;
+ toString << outDecSize;
+
+ writeBytes((unsigned char*)toString.str().c_str(),
+ sizeof(int), outFile.Get());
+ writeBytes((unsigned char*)outChunk, outDecSize, outFile.Get());
+ delete outChunk;
+ }
+ inChunk.reset(new unsigned char[chunkSize]);
- } while (0 == std::feof(inFile.Get()));
+ } while (0 == std::feof(inFile.Get()));
- outFile.Reset();
- inFile.Reset();
+ outFile.Reset();
+ inFile.Reset();
- LogDebug("File encrypted successfully");
- LogDebug("Remove plain-text file: " << fileName);
- if (0 != unlink(fileName.c_str()))
- {
- Throw(Exceptions::EncryptionFailed);
- }
+ LogDebug("File encrypted successfully");
+ LogDebug("Remove plain-text file: " << fileName);
+ if (0 != unlink(fileName.c_str()))
+ {
+ Throw(Exceptions::EncryptionFailed);
+ }
- LogDebug("Rename encrypted file");
- if (0 != std::rename(encFile.c_str(), fileName.c_str()))
- {
- Throw(Exceptions::EncryptionFailed);
+ LogDebug("Rename encrypted file");
+ if (0 != std::rename(encFile.c_str(), fileName.c_str()))
+ {
+ Throw(Exceptions::EncryptionFailed);
+ }
}
std::string realPath = fileName;