#include <dpl/utils/mime_type_utils.h>
#include <dpl/localization/LanguageTagsProvider.h>
#include <dpl/event/main_event_dispatcher.h>
+#include <FBaseByteBuffer.h>
+#include <security/FSecCrypto_TrustZoneService.h>
#include <wrt_plugin_module.h>
#include <profiling_util.h>
m_theme(""),
m_willRemoveContext(NULL),
m_encrypted(false),
- m_resDec(NULL),
m_widgetType(WrtDB::APP_TYPE_UNKNOWN),
m_initialized(false)
{
struct stat buf;
if (0 == stat(filePath.c_str(), &buf)) {
- if (NULL == m_resDec) {
- using namespace WrtDB;
- m_resDec = new
- WRTDecryptor::ResourceDecryptor(DPL::ToUTF8String(
- m_widgetTizenId));
- WrtDB::WidgetDAOReadOnly(m_widgetTizenId).
- getEncryptedFileList(m_encryptedFiles);
- }
-
const std::size_t fileSize = buf.st_size;
const std::size_t readBufSize = (fileSize > FILE_BUF_MAX_SIZE
? FILE_BUF_MAX_SIZE : fileSize);
std::unique_ptr<unsigned char[]> inChunk(new unsigned char[readBufSize]);
- std::unique_ptr<unsigned char[]> outChunk;
FILE* fp = fopen(filePath.c_str(), "rb");
if (NULL == fp) {
if (0 != readSize) {
LogDebug("resource is encrypted. decrypting....");
- int decSize = m_resDec->DecryptChunkByTrustZone(
- DPL::ToUTF8String(m_widgetTizenId), inChunk.get(),
- readSize);
- outChunk.reset(new unsigned char[decSize]);
- m_resDec->getDecryptStringByTrustZone(outChunk.get());
+ using namespace Tizen::Base;
+ ByteBuffer *getBuffer =
+ reinterpret_cast<ByteBuffer*>(DecryptChunkByTrustZone(inChunk.get(),
+ readSize));
memcpy(DecryptedString.get() + (PLAIN_CHUNK_SIZE * count++),
- outChunk.get(),
+ getBuffer->GetPointer(),
(readSize < PLAIN_CHUNK_SIZE ? readSize : PLAIN_CHUNK_SIZE));
+ getBuffer->Reset();
}
} while( 0 == std::feof(fp));
return std::string();
}
+void *Bundle::DecryptChunkByTrustZone(const unsigned char *inBuffer,
+ int inBufSize)
+{
+ using namespace Tizen::Base;
+ std::string pkgid(DPL::ToUTF8String(m_widgetTizenId));
+
+ const byte *b_pkgid = reinterpret_cast<const byte*>(pkgid.c_str());
+ ByteBuffer appInfo;
+ appInfo.Construct(pkgid.length());
+ appInfo.SetArray(b_pkgid, 0, pkgid.length());
+ appInfo.Flip();
+
+ Tizen::Security::Crypto::_TrustZoneService* pInstance;
+ pInstance = Tizen::Security::Crypto::_TrustZoneService::GetInstance();
+
+ ByteBuffer pBuf;
+ pBuf.Construct(inBufSize);
+ const byte *pByte = reinterpret_cast<const byte*>(inBuffer);
+ pBuf.SetArray(pByte, 0, inBufSize);
+ pBuf.Flip();
+
+ ByteBuffer *getBuffer = pInstance->_TrustZoneService::DecryptN(appInfo, pBuf);
+ return reinterpret_cast<void*>(getBuffer);
+}
+
void Bundle::requestSuspend()
{
LogDebug("Unregister callbacks");
#include <WKPageLoadTypes.h>
#include <WKBundlePage.h>
#include <dpl/string.h>
-#include <dpl/encryption/resource_decryption.h>
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
extern "C" {
std::set<JSGlobalContextRef> m_loadedContext;
JSGlobalContextRef m_willRemoveContext;
bool m_encrypted;
- WRTDecryptor::ResourceDecryptor *m_resDec;
WrtDB::EncryptedFileList m_encryptedFiles;
WrtDB::WidgetType m_widgetType;
bool m_initialized;
void requestResume();
void connectLoaderClientCallbacksToPage(WKBundlePageRef page);
+ void *DecryptChunkByTrustZone(const unsigned char *inBuffer,
+ int inBufSize);
};
#endif /* WRT_SRC_VIEW_WEBKIT2_WRT_WK2_BUNDLE_H_ */