int err = 0;
EVP_CIPHER_CTX ctx;
- std::unique_ptr< ISecretKey > pSecKey(reinterpret_cast< ISecretKey* >(GetDeviceUniqueKey(certMgrInfo, certMgrInfoLen, aesBlockLen)));
- SysTryReturnResult(NID_SEC_CERT, pSecKey != null, E_SYSTEM, "Failed to generate secret key.");
-
- std::unique_ptr< ByteBuffer > pKeyBuf(pSecKey->GetEncodedN());
- SysAssertf(pKeyBuf != null, "Failed to get encoded secret key.");
-
+ std::unique_ptr< char > pUniqueKey(GetDeviceUniqueKey(certMgrInfo, certMgrInfoLen, aesBlockLen));
+ SysTryReturnResult(NID_SEC_CERT, pUniqueKey != null, E_SYSTEM, "Failed to generate unique key.");
+
memset(uniqueKey, 0, aesBlockLen);
- memcpy(uniqueKey, reinterpret_cast< const char* >(pKeyBuf->GetPointer()), aesBlockLen);
+ memcpy(uniqueKey, pUniqueKey.get(), aesBlockLen);
*ppPrivKey = new (std::nothrow) byte[__privateKeyLen + aesBlockLen + 1];
SysTryReturnResult(NID_SEC_CERT, *ppPrivKey != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
long tempkeyLen = 0;
byte* pPrivKey = null;
- std::unique_ptr< ISecretKey > pSecKey(reinterpret_cast< ISecretKey* >(GetDeviceUniqueKey(certMgrInfo, certMgrInfoLen, aesBlockLen)));
- SysTryReturnResult(NID_SEC_CERT, pSecKey != null, E_SYSTEM, "Failed to generate secret key.");
-
- std::unique_ptr< ByteBuffer > pKeyBuf(pSecKey->GetEncodedN());
- SysAssertf(pKeyBuf != null, "Failed to get encoded secret key.");
+ std::unique_ptr< char > pUniqueKey(GetDeviceUniqueKey(certMgrInfo, certMgrInfoLen, aesBlockLen));
+ SysTryReturnResult(NID_SEC_CERT, pUniqueKey != null, E_SYSTEM, "Failed to generate unique key.");
memset(uniqueKey, 0, aesBlockLen);
- memcpy(uniqueKey, reinterpret_cast< const char* >(pKeyBuf->GetPointer()), aesBlockLen);
+ memcpy(uniqueKey, pUniqueKey.get(), aesBlockLen);
std::unique_ptr< const unsigned char > pTempPrivateKey(new unsigned char[__privateKeyLen + 1]);
SysTryReturnResult(NID_SEC_CERT, pTempPrivateKey != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");