Call TA to get the max chunk size 51/296251/4
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 24 Jul 2023 09:42:18 +0000 (11:42 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 25 Jul 2023 06:56:11 +0000 (08:56 +0200)
Change-Id: Iec297646564b0a49d2966fcec1ec922bac1b7615

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

index 5a19cba..efad483 100644 (file)
@@ -844,6 +844,10 @@ void deriveKBKDF(const RawBuffer &secretId,
                                                                                          keyHash);
 }
 
+size_t maxChunkSize()
+{
+       return TrustZoneContext::Instance().getMaxChunkSize();
+}
 
 } // namespace Internals
 } // namespace TZ
index 8797065..98171a5 100644 (file)
@@ -162,6 +162,8 @@ void deriveKBKDF(const RawBuffer &secretId,
                                 const RawBuffer &keyPwdIV,
                                 RawBuffer &keyTag,
                                 const RawBuffer &keyHash);
+
+size_t maxChunkSize();
 } // namespace Internals
 } // namespace TZ
 } // namespace Crypto
index 958da3a..23ba831 100644 (file)
@@ -208,6 +208,11 @@ void Store::unpack(const RawBuffer &packed,
        }
 }
 
+size_t Store::maxChunkSize() const
+{
+       return Internals::maxChunkSize();
+}
+
 } // namespace TZ
 } // namespace Crypto
 } // namespace CKM
index 439cec4..67b480c 100644 (file)
@@ -55,7 +55,7 @@ public:
                                           RawBuffer &data,
                                           RawBuffer &iv,
                                           RawBuffer &tag);
-       size_t maxChunkSize() const override { return 4; } // TODO get it from somewhere
+       size_t maxChunkSize() const override;
 
        // TODO device key ID is needed here to support importEncrypted
 };
index a457462..2c013ae 100644 (file)
@@ -948,6 +948,19 @@ void TrustZoneContext::executeKbkdf(const RawBuffer& secretId,
        LogDebug("Derived object ID is (hex): " << rawToHexString(keyHash));
 }
 
+uint32_t TrustZoneContext::getMaxChunkSize()
+{
+       // command ID = CMD_GET_MAX_CHUNK_SIZE
+       LogDebug("TrustZoneContext::getMaxChunkSize");
+
+       TEEC_Operation op;
+       op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_OUTPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE);
+
+       Execute(CMD_GET_MAX_CHUNK_SIZE, &op);
+
+       return op.params[0].value.b;
+}
+
 void TrustZoneContext::Initialize()
 {
        TEEC_Operation op;
index 51f9be1..9fd3a1e 100644 (file)
@@ -199,6 +199,8 @@ public:
                                          RawBuffer &keyTag,
                                          const RawBuffer &keyHash);
 
+       uint32_t getMaxChunkSize();
+
 private:
        TrustZoneContext();
        ~TrustZoneContext();