#include <unique_ptr.h>
#include <stdlib.h>
+#include <dukgen.h>
+
#include <FBaseSysLog.h>
#include <FBase_StringConverter.h>
#include <FBaseString.h>
#include <FAppPkg_PackageInfoImpl.h>
+#include <FSecSecretKey.h>
#include <FSecCryptoAesCipher.h>
#include <FSecCryptoSha1Hmac.h>
#include <FSecCryptoSha1Hash.h>
#include <FBaseColArrayList.h>
-#include "FSec_DeviceKeyGenerator.h"
#include "FSec_PrivilegeInfo.h"
using namespace Tizen::App;
r = cipherDec.Construct(L"CBC/128/PKCS7PADDING", CIPHER_DECRYPT);
SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
- pKey.reset(_DeviceKeyGenerator::GenerateDeviceKeyN(_KEY_LEN));
+ pKey.reset(GetDeviceUniqueKeyN());
SysTryReturnResult(NID_SEC, pKey != null, E_SYSTEM, "An unexpected system error occurred.");
r = cipherDec.SetKey(*pKey.get());
r = cipherEnc.Construct(L"CBC/128/PKCS7PADDING", CIPHER_ENCRYPT);
SysTryReturnResult(NID_SEC, r == E_SUCCESS, E_SYSTEM, "An unexpected system error occurred.");
- pKey.reset(_DeviceKeyGenerator::GenerateDeviceKeyN(_KEY_LEN));
+ pKey.reset(GetDeviceUniqueKeyN());
SysTryReturnResult(NID_SEC, pKey != null, E_SYSTEM, "An unexpected system error occurred.");
r = cipherEnc.SetKey(*(pKey.get()));
pHmac.reset(new (std::nothrow) Sha1Hmac());
SysTryReturnResult(NID_SEC, pHmac != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
- pKey.reset(_DeviceKeyGenerator::GenerateDeviceKeyN(_KEY_LEN));
+ pKey.reset(GetDeviceUniqueKeyN());
SysTryReturnResult(NID_SEC, pKey != null, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
r = pHmac->SetKey(*(pKey.get()));
pHmac.reset(new (std::nothrow) Sha1Hmac());
SysTryReturnResult(NID_SEC, pHmac != null, E_OUT_OF_MEMORY, "Memory allocation is failed.");
- pKey.reset(_DeviceKeyGenerator::GenerateDeviceKeyN(_KEY_LEN));
+ pKey.reset(GetDeviceUniqueKeyN());
SysTryReturnResult(NID_SEC, pKey != null, E_SYSTEM, "An unexpected system error occurred.");
r = pHmac->SetKey(*(pKey.get()));
pHmac.reset(new (std::nothrow) Sha1Hmac());
SysTryReturnResult(NID_SEC, pHmac != null, E_OUT_OF_MEMORY, "Memory allocation is failed.");
- pKey.reset(_DeviceKeyGenerator::GenerateDeviceKeyN(_KEY_LEN));
+ pKey.reset(GetDeviceUniqueKeyN());
SysTryReturnResult(NID_SEC, pKey != null, E_SYSTEM, "An unexpected system error occurred.");
r = pHmac->SetKey(*(pKey.get()));
return r;
}
+ISecretKey*
+_PrivilegeInfo::GetDeviceUniqueKeyN(void)
+{
+ result r = E_SUCCESS;
+ ByteBuffer* pTempValue = null;
+ ISecretKey* pKey = null;
+
+ char uniqueInfo[_INFO_LEN] =
+ {
+ 0x09, 0x25, 0x19, 0x87, 0xBF, 0x02, 0x14, 0x19,
+ 0x88, 0xDD, 0x12, 0x30, 0x19, 0x86, 0xAD, 0xED
+ };
+
+ char* pUniqueKey = null;
+ pUniqueKey = GetDeviceUniqueKey(uniqueInfo, _INFO_LEN, _KEY_LEN);
+ SysTryCatch(NID_SEC, pUniqueKey != null, , E_SYSTEM, "[E_SYSTEM] Failed to generate the unique key.");
+
+ pTempValue = new (std::nothrow) ByteBuffer();
+ SysTryCatch(NID_SEC, pTempValue != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+ r = pTempValue->Construct(_KEY_LEN);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, , r, "[%s] Failed to generate device unique key.", GetErrorMessage(r));
+
+ r = pTempValue->SetArray(reinterpret_cast <byte*>(pUniqueKey), 0, _KEY_LEN);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, , r, "[%s] Failed to generate device unique key.", GetErrorMessage(r));
+
+ pTempValue->Flip();
+
+ pKey = new (std::nothrow) SecretKey();
+ SysTryCatch(NID_SEC, pKey != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+ r = pKey->SetKey(*pTempValue);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, , r, "[%s] Failed to generate device unique key.", GetErrorMessage(r));
+
+ if (pUniqueKey != null)
+ {
+ free(pUniqueKey);
+ }
+ delete pTempValue;
+
+ return pKey;
+
+CATCH:
+ if (pUniqueKey != null)
+ {
+ free(pUniqueKey);
+ }
+ delete pTempValue;
+ delete pKey;
+
+ return null;
+}
+
}} //Tizen::Security
#include <stdlib.h>
#include <pthread.h>
#include <unique_ptr.h>
+#include <dukgen.h>
+
#include <FAppPkg_PackageInfoImpl.h>
#include <FAppPkg_PackageManagerImpl.h>
#include <FBaseString.h>
#include <FBaseSysLog.h>
#include <FSec_AccessControlTypes.h>
#include <FSec_PrivilegeManager.h>
+#include <FSecSecretKey.h>
#include <FSecCryptoAesCipher.h>
#include <FSecCryptoSha1Hmac.h>
#include <FBase_StringConverter.h>
#include <FBaseInternalTypes.h>
-#include <FSec_DeviceKeyGenerator.h>
+
#include "FSec_PrivilegeManagerServer.h"
using namespace Tizen::App;
r = cipherEnc.Construct(L"CBC/128/PKCS7PADDING", CIPHER_ENCRYPT);
SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
- pKey = _DeviceKeyGenerator::GenerateDeviceKeyN(_KEY_LEN);
+ pKey = GetDeviceUniqueKeyN();
SysTryCatch(NID_SEC, pKey != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
r = cipherEnc.SetKey(*pKey);
pHmac = new (std::nothrow) Sha1Hmac();
SysTryCatch(NID_SEC, pHmac != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
- pKey = _DeviceKeyGenerator::GenerateDeviceKeyN(_KEY_LEN);
+ pKey = GetDeviceUniqueKeyN();
SysTryCatch(NID_SEC, pKey != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
r = pHmac->SetKey(*pKey);
return r;
}
+ISecretKey*
+_PrivilegeManagerServer::GetDeviceUniqueKeyN(void)
+{
+ result r = E_SUCCESS;
+ ByteBuffer* pTempValue = null;
+ ISecretKey* pKey = null;
+
+ char uniqueInfo[_INFO_LEN] =
+ {
+ 0x09, 0x25, 0x19, 0x87, 0xBF, 0x02, 0x14, 0x19,
+ 0x88, 0xDD, 0x12, 0x30, 0x19, 0x86, 0xAD, 0xED
+ };
+
+ char* pUniqueKey = null;
+ pUniqueKey = GetDeviceUniqueKey(uniqueInfo, _INFO_LEN, _KEY_LEN);
+ SysTryCatch(NID_SEC, pUniqueKey != null, , E_SYSTEM, "[E_SYSTEM] Failed to generate the unique key.");
+
+ pTempValue = new (std::nothrow) ByteBuffer();
+ SysTryCatch(NID_SEC, pTempValue != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+ r = pTempValue->Construct(_KEY_LEN);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, , r, "[%s] Failed to generate device unique key.", GetErrorMessage(r));
+
+ r = pTempValue->SetArray(reinterpret_cast <byte*>(pUniqueKey), 0, _KEY_LEN);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, , r, "[%s] Failed to generate device unique key.", GetErrorMessage(r));
+
+ pTempValue->Flip();
+
+ pKey = new (std::nothrow) SecretKey();
+ SysTryCatch(NID_SEC, pKey != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
+
+ r = pKey->SetKey(*pTempValue);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, , r, "[%s] Failed to generate device unique key.", GetErrorMessage(r));
+
+ if (pUniqueKey != null)
+ {
+ free(pUniqueKey);
+ }
+ delete pTempValue;
+
+ return pKey;
+
+CATCH:
+ if (pUniqueKey != null)
+ {
+ free(pUniqueKey);
+ }
+ delete pTempValue;
+ delete pKey;
+
+ return null;
+}
}} //Tizen::Security