From: Krzysztof Jackiewicz Date: Thu, 3 Aug 2023 08:55:48 +0000 (+0200) Subject: Deserialize tags only if password was given X-Git-Tag: accepted/tizen/unified/20230808.170151~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c3bd3d6e3622821b5a07970be9fa705bc6bcd254;p=platform%2Fcore%2Fsecurity%2Fkey-manager.git Deserialize tags only if password was given Change-Id: I1c598e17740785e4bd49edc120b6844ebe65e88a --- diff --git a/src/manager/crypto/tz-backend/tz-context.cpp b/src/manager/crypto/tz-backend/tz-context.cpp index 7a6e9215..ffa41a0b 100644 --- a/src/manager/crypto/tz-backend/tz-context.cpp +++ b/src/manager/crypto/tz-backend/tz-context.cpp @@ -249,28 +249,27 @@ void TrustZoneContext::GenerateAKey(tz_command commandId, const RawBuffer &hashPriv, const RawBuffer &hashPub) { - uint32_t pubTagSize = 0; - uint32_t privTagSize = 0; uint32_t pubPwdExists = pubPwd.empty() ? 0 : 1; - if (pubPwdExists) { - pubTagSize = Params::DEFAULT_AES_GCM_TAG_LEN_BYTES; - } + TZSerializer sOut; + if (pubPwdExists) + sOut.Push(new TZSerializableBinary(Params::DEFAULT_AES_GCM_TAG_LEN_BYTES)); + uint32_t privPwdExists = privPwd.empty() ? 0 : 1; - if (privPwdExists) { - privTagSize = Params::DEFAULT_AES_GCM_TAG_LEN_BYTES; - } + if (privPwdExists) + sOut.Push(new TZSerializableBinary(Params::DEFAULT_AES_GCM_TAG_LEN_BYTES)); push(sIn, EncPwd{pubPwd, pubPwdIv}, EncPwd{privPwd, privPwdIv}, hashPriv, hashPub); TrustZoneMemory inMemory(m_Context, sIn.GetSize(), TEEC_MEM_INPUT); sIn.Serialize(inMemory); - TZSerializer sOut; - sOut.Push(new TZSerializableBinary(pubTagSize)); - sOut.Push(new TZSerializableBinary(privTagSize)); - TrustZoneMemory outMemory(m_Context, sOut.GetSize(), TEEC_MEM_OUTPUT); - TEEC_Operation op = makeOp(TEEC_VALUE_INOUT, inMemory, outMemory); + TEEC_Operation op; + if (sOut.GetSize() == 0) { + op = makeOp(TEEC_VALUE_INOUT, inMemory); + } else { + op = makeOp(TEEC_VALUE_INOUT, inMemory, outMemory); + } op.params[0].value.b = genParam; Execute(commandId, &op);