From 3d3465f96895b5a6eab2b211cc8742a5902bdd76 Mon Sep 17 00:00:00 2001 From: Krzysztof Jackiewicz Date: Mon, 10 Jul 2023 17:31:33 +0200 Subject: [PATCH] Fix TZ backend issues * Add missing namespaces * Include ctx.cpp in TZ source list * Add missing operation id to internal TZ calls Change-Id: I59e71b7af5a1c418f797e7d915b8a9d1fc456edf --- CMakeLists.txt | 1 + src/manager/crypto/sw-backend/ctx.cpp | 2 ++ src/manager/crypto/sw-backend/ctx.h | 2 ++ src/manager/crypto/tz-backend/ctx.cpp | 6 ++++-- src/manager/crypto/tz-backend/ctx.h | 2 ++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6af5d8c..2ad368e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,7 @@ IF (TZ_BACKEND_ENABLED) SET(TZ_BACKEND_SOURCES ${KEY_MANAGER_PATH}/crypto/tz-backend/internals.cpp ${KEY_MANAGER_PATH}/crypto/tz-backend/obj.cpp + ${KEY_MANAGER_PATH}/crypto/tz-backend/ctx.cpp ${KEY_MANAGER_PATH}/crypto/tz-backend/store.cpp ${KEY_MANAGER_PATH}/crypto/tz-backend/tz-context.cpp ${KEY_MANAGER_PATH}/crypto/tz-backend/tz-memory.cpp diff --git a/src/manager/crypto/sw-backend/ctx.cpp b/src/manager/crypto/sw-backend/ctx.cpp index cffd4f4..1dcf0f7 100644 --- a/src/manager/crypto/sw-backend/ctx.cpp +++ b/src/manager/crypto/sw-backend/ctx.cpp @@ -20,6 +20,7 @@ namespace CKM { namespace Crypto { +namespace SW { namespace { constexpr uint8_t STATE_INITIALIZED = 1; @@ -109,5 +110,6 @@ RawBuffer CipherCtx::finalize(const RawBuffer& input) return tag; } +} // namespace SW } // namespace Crypto } // namespace CKM diff --git a/src/manager/crypto/sw-backend/ctx.h b/src/manager/crypto/sw-backend/ctx.h index 04f65a3..428997f 100644 --- a/src/manager/crypto/sw-backend/ctx.h +++ b/src/manager/crypto/sw-backend/ctx.h @@ -23,6 +23,7 @@ namespace CKM { namespace Crypto { +namespace SW { class CipherCtx : public GCtx { public: @@ -38,5 +39,6 @@ private: uint8_t m_state; }; +} // namespace SW } // namespace Crypto } // namespace CKM diff --git a/src/manager/crypto/tz-backend/ctx.cpp b/src/manager/crypto/tz-backend/ctx.cpp index 1fcc80b..db877d8 100644 --- a/src/manager/crypto/tz-backend/ctx.cpp +++ b/src/manager/crypto/tz-backend/ctx.cpp @@ -20,6 +20,7 @@ namespace CKM { namespace Crypto { +namespace TZ { void CipherCtx::customize(const CryptoAlgorithm& algo) { @@ -32,7 +33,7 @@ void CipherCtx::customize(const CryptoAlgorithm& algo) RawBuffer CipherCtx::update(const RawBuffer& input) { - return Internals::updateCipher(input); + return Internals::updateCipher(m_opId, input); } RawBuffer CipherCtx::finalize(const RawBuffer& input) @@ -41,8 +42,9 @@ RawBuffer CipherCtx::finalize(const RawBuffer& input) * It is assumed that finalize for GCM encryption will return the GCM tag only. * In case of GCM decryption the tag will be passed as finalizeCipher argument. */ - return Internals::finalizeCipher(input); + return Internals::finalizeCipher(m_opId, input); } +} // namespace TZ } // namespace Crypto } // namespace CKM diff --git a/src/manager/crypto/tz-backend/ctx.h b/src/manager/crypto/tz-backend/ctx.h index d12b5ce..32eba26 100644 --- a/src/manager/crypto/tz-backend/ctx.h +++ b/src/manager/crypto/tz-backend/ctx.h @@ -20,6 +20,7 @@ namespace CKM { namespace Crypto { +namespace TZ { class CipherCtx : public GCtx { public: @@ -33,5 +34,6 @@ private: uint32_t m_opId; }; +} // namespace TZ } // namespace Crypto } // namespace CKM -- 2.7.4