[Release] wrt-installer_0.1.38
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_encrypt_resource.cpp
index ee55ea5..647817e 100644 (file)
@@ -193,11 +193,13 @@ Tizen::Base::ByteBuffer* EncryptChunkByTrustZone(
     ByteBuffer pBuf;
     pBuf.Construct(pBufSize);
     const byte *pByte = reinterpret_cast<const byte*>(plainBuffer);
-    pBuf.SetArray(pByte, 0, pBufSize);
+    if (pBuf.SetArray(pByte, 0, pBufSize) != E_SUCCESS) {
+        LogDebug("Couldnot set pBuf");
+        return NULL;
+    }
     pBuf.Flip();
 
-    ByteBuffer* getBuffer = pInstance->_TrustZoneService::EncryptN(*appInfo, pBuf);
-    return getBuffer;
+    return pInstance->_TrustZoneService::EncryptN(*appInfo, pBuf);
 }
 
 Tizen::Base::ByteBuffer* TEST_dec(
@@ -213,12 +215,13 @@ Tizen::Base::ByteBuffer* TEST_dec(
     ByteBuffer pBuf;
     pBuf.Construct(pBufSize);
     const byte *pByte = reinterpret_cast<const byte*>(plainBuffer);
-    pBuf.SetArray(pByte, 0, pBufSize);
+    if (pBuf.SetArray(pByte, 0, pBufSize) != E_SUCCESS) {
+        LogDebug("Couldnot set pBuf");
+        return NULL;
+    }
     pBuf.Flip();
 
-    ByteBuffer* getBufferTEST =
-        pInstance->_TrustZoneService::DecryptN(*appInfo, pBuf);
-    return getBufferTEST;
+    return pInstance->_TrustZoneService::DecryptN(*appInfo, pBuf);
 }
 }
 
@@ -329,7 +332,12 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName)
             pkgid.c_str());
     ByteBuffer appInfo;
     appInfo.Construct(pkgid.length());
-    appInfo.SetArray(b_pkgid, 0, pkgid.length());
+
+    if (appInfo.SetArray(b_pkgid, 0, pkgid.length()) != E_SUCCESS) {
+        LogDebug("Couldnot set appInfo");
+        return;
+    }
+
     appInfo.Flip();
 
     do
@@ -339,6 +347,10 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName)
             ByteBuffer *getBuffer = EncryptChunkByTrustZone(
                     &appInfo,
                     inChunk.get(), bytesRead);
+            if (getBuffer == NULL) {
+                ThrowMsg(Exceptions::EncryptionFailed,
+                        "Encryption Failed using TrustZone");
+            }
             int decBufSize = getBuffer->GetRemaining();
 
             outChunk.reset(new unsigned char[decBufSize]);