add debug log and fix a bug 58/282558/3
authorisaac2.lee <isaac2.lee@samsung.com>
Thu, 6 Oct 2022 01:17:12 +0000 (10:17 +0900)
committerisaac2.lee <isaac2.lee@samsung.com>
Thu, 6 Oct 2022 01:24:50 +0000 (10:24 +0900)
Change-Id: I35d284cb29ec3bfe53500f4473994ed5c8217e61

src/manager/crypto/se-backend/internals.cpp
src/manager/service/key-provider.cpp

index 65260ed..871dcc9 100644 (file)
@@ -117,9 +117,9 @@ void generateAKey(const CryptoAlgorithm &alg,
 RawBuffer encryptWithDbpKey(const unsigned char* key, const uint32_t key_len,
                                                const unsigned char* iv, const uint32_t iv_len)
 {
-
-       unsigned char* output_data;
-       uint32_t output_len;
+       unsigned char* output_data = NULL;
+       uint32_t output_len = 0;
+       LogDebug("DBP Key will be encrypted on SE backend");
 
        int ret = kmsb_failure_retry(std::bind(kmsb_encrypt_with_dbp_key,
                                                                SE_BACKEND_DBP_SCHEME_VERSION,
@@ -127,7 +127,7 @@ RawBuffer encryptWithDbpKey(const unsigned char* key, const uint32_t key_len,
                                                                iv, iv_len,
                                                                &output_data, &output_len));
        if (ret == KMSB_ERROR_NO_KEY) {
-               ret = kmsb_failure_retry(std::bind(kmsb_generate_dbp_key, 
+               ret = kmsb_failure_retry(std::bind(kmsb_generate_dbp_key,
                                                                false));
                if (ret != KMSB_ERROR_NONE) {
                        LogError("Generate Key: SE Internal error: " << ret);
index b860c49..ce908c7 100644 (file)
@@ -139,7 +139,7 @@ KeyData makePKEK1(const KeyComponentsInfoDKEK& keyInfo, const Password &password
 #if SE_BACKEND_ENABLED
        RawBuffer salt;
        if (keyInfo.backend == (int)CryptoBackend::SecureElement) {
-               RawBuffer salt = Crypto::SE::Internals::encryptWithDbpKey((unsigned char*)keyInfo.salt, MAX_SALT_SIZE,
+               salt = Crypto::SE::Internals::encryptWithDbpKey((unsigned char*)keyInfo.salt, MAX_SALT_SIZE,
                                                                                (unsigned char*)keyInfo.iv, MAX_IV_SIZE);
        } else {
                salt = RawBuffer(keyInfo.salt, keyInfo.salt + MAX_SALT_SIZE);