Fix the logic for getting DeviceUniqueKey
authorso.yu <so.yu@samsung.com>
Sun, 7 Apr 2013 13:33:55 +0000 (22:33 +0900)
committerso.yu <so.yu@samsung.com>
Sun, 7 Apr 2013 13:34:36 +0000 (22:34 +0900)
Change-Id: Ibe2c4e67312d11cdecfaa9c66369c97893c27724
Signed-off-by: so.yu <so.yu@samsung.com>
src/security/cert/FSecCert_CertPrivateKeyInfo.cpp

index 2dbf462..343693c 100644 (file)
@@ -104,14 +104,11 @@ _CertPrivateKeyInfo::GetEncDecPrivateKeyN(int& keyLen, byte** ppPrivKey, int enc
        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.");
@@ -176,14 +173,11 @@ _CertPrivateKeyInfo::GetPkcs8EncDecKeyN(int& keyLen, byte** ppPrivKey, int encDe
        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.");