Pass password to CMD_GET_DATA_SIZE
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Wed, 9 Aug 2023 15:31:21 +0000 (17:31 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Mon, 21 Aug 2023 12:19:27 +0000 (14:19 +0200)
In case of encrypted objects the password may be necessary do get the
actual size.

Change-Id: I5636325a8a120c0226ab5cc06ddef2aa05b96992

src/manager/crypto/tz-backend/tz-context.cpp
src/manager/crypto/tz-backend/tz-context.h

index b2bdf31..9bfc390 100644 (file)
@@ -774,7 +774,7 @@ RawBuffer TrustZoneContext::exportWrappedKey(const RawBuffer &wrappingKeyId,
        sIn.Serialize(inMemory);
 
        uint32_t dataSize = 0;
-       GetDataSize(keyToWrapId, keyToWrapType, dataSize);
+       GetDataSize(keyToWrapId, keyToWrapPwd, keyToWrapType, dataSize);
 
        LogDebug("GetData data_size = [" << dataSize << "]");
 
@@ -801,13 +801,14 @@ RawBuffer TrustZoneContext::exportWrappedKey(const RawBuffer &wrappingKeyId,
 }
 
 void TrustZoneContext::GetDataSize(const RawBuffer &dataId,
+                                                                  const Pwd &pwd,
                                                                   const tz_data_type type,
                                                                   uint32_t &dataSize)
 {
        // command ID = CMD_GET_DATA_SIZE
        LogDebug("Object ID (passed to CMD_GET_DATA_SIZE) is (hex): " << rawToHexString(dataId));
 
-       auto sIn = makeSerializer(dataId, type);
+       auto sIn = makeSerializer(dataId, pwd, type);
        TrustZoneMemory inMemory(m_Context, sIn.GetSize(), TEEC_MEM_INPUT);
        sIn.Serialize(inMemory);
 
@@ -830,7 +831,7 @@ void TrustZoneContext::getData(const RawBuffer &dataId,
        sIn.Serialize(inMemory);
 
        uint32_t data_size = 0;
-       GetDataSize(dataId, type, data_size);
+       GetDataSize(dataId, pwd, type, data_size);
 
        LogDebug("GetData data_size = [" << data_size << "]");
 
index 9471807..2033cf7 100644 (file)
@@ -216,7 +216,10 @@ private:
        void Destroy();
        void Reload();
 
-       void GetDataSize(const RawBuffer &dataId, const tz_data_type type, uint32_t &dataSize);
+       void GetDataSize(const RawBuffer &dataId,
+                                        const Pwd &pwd,
+                                        const tz_data_type type,
+                                        uint32_t &dataSize);
 
        void Execute(tz_command commandID, TEEC_Operation* op);