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<std::string>& getSupportedForEncryption()
{
{
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(
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");