summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>2024-11-13 14:59:39 +0100
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>2024-11-13 15:50:38 +0100
commit63ed38a193adfebc1c356d38a5f6b74924819ab6 (patch)
tree90306b4ab411eb86dcfbbfd22de4a67b3a8dad43
parente8d95c34ff40dfe4fba27fc63702dd12490e64b5 (diff)
downloadkey-manager-ta-tizen.tar.gz
key-manager-ta-tizen.tar.bz2
key-manager-ta-tizen.zip
Fix missing [outbuf] param initializationtizen
Change-Id: I1d5b145d6ebe184150e7ed39fe13ef9b0bf902bd
-rw-r--r--ta/src/cmd_exec.c30
-rw-r--r--ta/src/crypto_asymmetric.c6
-rw-r--r--ta/src/crypto_auth.c6
-rw-r--r--ta/src/crypto_derive.c2
-rw-r--r--ta/src/crypto_digest.c2
-rw-r--r--ta/src/crypto_symmetric.c2
6 files changed, 21 insertions, 27 deletions
diff --git a/ta/src/cmd_exec.c b/ta/src/cmd_exec.c
index c75f787..25f5977 100644
--- a/ta/src/cmd_exec.c
+++ b/ta/src/cmd_exec.c
@@ -907,7 +907,7 @@ static TEE_Result KM_GetSecretValue(KM_BinaryData *secret_id, KM_BinaryData* sec
LOG("KM_DecryptKey or KM_OpenKey has failed with=%x. with_secret_pwd=%d", ret, with_secret_pwd);
goto clean;
}
- size_t out_size_t;
+ size_t out_size_t = output.data_size;
ret = TEE_GetObjectBufferAttribute(key_handle, TEE_ATTR_SECRET_VALUE,
output.data, &out_size_t);
if (ret != TEE_SUCCESS) {
@@ -3324,7 +3324,7 @@ TEE_Result KM_ExecCmdCipherUpdate(TEE_Param param[4])
}
// Update Cipher
- size_t out_size_t;
+ size_t out_size_t = output.data_size;
ret = TEE_AEUpdate(op, data.data, data.data_size, output.data, &out_size_t);
if( ret != TEE_SUCCESS) {
LOG("Failed in TEE_AEUpdate(). ret=%x", ret);
@@ -3360,7 +3360,8 @@ TEE_Result KM_ExecCmdCipherFinalize(TEE_Param param[4])
uint32_t tag_len_bytes;
listNode *ctx = NULL;
KM_BinaryData output = {0, NULL};
- KM_BinaryData dummy_output = {0, NULL};
+ void* dummy_output = NULL;
+ size_t dummy_output_size_t = 0;
void *in_buffer = param[1].memref.buffer;
void *out_buffer = param[2].memref.buffer;
@@ -3393,13 +3394,12 @@ TEE_Result KM_ExecCmdCipherFinalize(TEE_Param param[4])
ret = TEE_ERROR_BAD_PARAMETERS;
goto clean;
}
- size_t out_size_t;
ret = TEE_AEDecryptFinal(op, NULL, 0,
- dummy_output.data, &out_size_t,
+ dummy_output, &dummy_output_size_t,
data.data, data.data_size);
- if (ret == TEE_SUCCESS && out_size_t != 0) {
- LOG("The output size of TEE_AEDecryptFinal() should be zero, but not. output_size=%d",
- dummy_output.data_size);
+ if (ret == TEE_SUCCESS && dummy_output_size_t != 0) {
+ LOG("The output size of TEE_AEDecryptFinal() should be zero, but not. dummy_output_size_t=%zu",
+ dummy_output_size_t);
ret = TEE_ERROR_GENERIC;
goto clean;
}
@@ -3418,16 +3418,10 @@ TEE_Result KM_ExecCmdCipherFinalize(TEE_Param param[4])
ret = TEE_ERROR_OUT_OF_MEMORY;
goto clean;
}
- size_t out_size_t;
- size_t tag_size_t;
+ size_t tag_size_t = output.data_size;
ret = TEE_AEEncryptFinal(op, NULL, 0,
- dummy_output.data, &out_size_t,
+ dummy_output, &dummy_output_size_t,
output.data, &tag_size_t);
- if (out_size_t > UINT32_MAX) {
- LOG("TEE_AEEncryptFinal returned too big output=%zu.", out_size_t);
- ret = TEE_ERROR_GENERIC;
- goto clean;
- }
if (tag_size_t > UINT32_MAX) {
LOG("TEE_AEEncryptFinal returned too big tag=%zu.", tag_size_t);
ret = TEE_ERROR_GENERIC;
@@ -3452,8 +3446,8 @@ TEE_Result KM_ExecCmdCipherFinalize(TEE_Param param[4])
clean:
// Remove Stored Operation. Operation & Key will be freed too.
ctxl_delete_node_id(op_id);
- if (dummy_output.data != NULL)
- TEE_Free(dummy_output.data);
+ if (dummy_output != NULL)
+ TEE_Free(dummy_output);
if (output.data != NULL)
TEE_Free(output.data);
return ret;
diff --git a/ta/src/crypto_asymmetric.c b/ta/src/crypto_asymmetric.c
index 88f8589..45aa185 100644
--- a/ta/src/crypto_asymmetric.c
+++ b/ta/src/crypto_asymmetric.c
@@ -30,7 +30,7 @@ TEE_Result KM_AsymmetricEncrypt(TEE_OperationHandle hndl, void *input, uint32_t
{
TEE_Result ret = TEE_SUCCESS;
- size_t out_size_t;
+ size_t out_size_t = *output_size;
ret = TEE_AsymmetricEncrypt(hndl, NULL, 0, input, input_size, output, &out_size_t);
if (TEE_SUCCESS != ret) {
LOG("TEE_AsymmetricEncrypt has failed with=%x.", ret);
@@ -51,7 +51,7 @@ TEE_Result KM_AsymmetricDecrypt(TEE_OperationHandle hndl, void *input, uint32_t
{
TEE_Result ret = TEE_SUCCESS;
- size_t out_size_t;
+ size_t out_size_t = *output_size;
ret = TEE_AsymmetricDecrypt(hndl, NULL, 0, input, input_size, output, &out_size_t);
if (TEE_SUCCESS != ret) {
LOG("TEE_AsymmetricDecrypt has failed with=%x.", ret);
@@ -74,7 +74,7 @@ TEE_Result KM_AsymmetricSign(TEE_OperationHandle hndl, void *digest, uint32_t di
void *out;
uint32_t out_len;
- size_t sig_size_t;
+ size_t sig_size_t = *sig_size;
ret = TEE_AsymmetricSignDigest(hndl, NULL, 0, digest, digest_size, signature, &sig_size_t);
if (TEE_SUCCESS != ret) {
LOG("TEE_AsymmetricSignDigest has failed with=%x.", ret);
diff --git a/ta/src/crypto_auth.c b/ta/src/crypto_auth.c
index efbe520..06ea0d6 100644
--- a/ta/src/crypto_auth.c
+++ b/ta/src/crypto_auth.c
@@ -49,8 +49,8 @@ TEE_Result KM_AuthEncrypt(TEE_OperationHandle hndl, void *iv, uint32_t iv_size,
TEE_AEUpdateAAD(hndl, aad, aad_size);
}
- size_t out_size_t;
- size_t tag_size_t;
+ size_t out_size_t = *out_size;
+ size_t tag_size_t = *tag_size;
ret = TEE_AEEncryptFinal(hndl, data, data_size, out, &out_size_t, tag, &tag_size_t);
if (TEE_SUCCESS != ret) {
LOG("TEE_AEEncryptFinal failed with error=%x.", ret);
@@ -95,7 +95,7 @@ TEE_Result KM_AuthDecrypt(TEE_OperationHandle hndl, void *iv, uint32_t iv_size,
TEE_AEUpdateAAD(hndl, aad, aad_size);
}
- size_t out_size_t;
+ size_t out_size_t = *out_size;
ret = TEE_AEDecryptFinal(hndl, data, data_size, out, &out_size_t, tag, tag_size);
if (TEE_SUCCESS != ret) {
LOG("TEE_AEDecryptFinal failed with error=%x.", ret);
diff --git a/ta/src/crypto_derive.c b/ta/src/crypto_derive.c
index 9cf94d9..e8a20e0 100644
--- a/ta/src/crypto_derive.c
+++ b/ta/src/crypto_derive.c
@@ -42,7 +42,7 @@ TEE_Result KM_DeriveKeyDoHMACIteration(TEE_OperationHandle op,
TEE_Result ret = TEE_SUCCESS;
TEE_MACInit(op, NULL, 0);
- size_t out_size_t;
+ size_t out_size_t = *out_size;
ret = TEE_MACComputeFinal(op, in, in_size, out, &out_size_t);
if (ret != TEE_SUCCESS) {
LOG("Failed to compute MAC: %x", ret);
diff --git a/ta/src/crypto_digest.c b/ta/src/crypto_digest.c
index 45a8229..cb915da 100644
--- a/ta/src/crypto_digest.c
+++ b/ta/src/crypto_digest.c
@@ -30,7 +30,7 @@ TEE_Result KM_Digest(TEE_OperationHandle hndl, void *input, uint32_t input_size,
TEE_Result ret = TEE_SUCCESS;
LOG("Digest");
- size_t out_size_t;
+ size_t out_size_t = *output_size;
ret = TEE_DigestDoFinal(hndl, input, input_size, output, &out_size_t);
if (ret != TEE_SUCCESS) {
LOG("TEE_DigestDoFinal has failed with=%x.", ret);
diff --git a/ta/src/crypto_symmetric.c b/ta/src/crypto_symmetric.c
index 5ac69e5..2a35f6e 100644
--- a/ta/src/crypto_symmetric.c
+++ b/ta/src/crypto_symmetric.c
@@ -116,7 +116,7 @@ TEE_Result KM_SymmetricCrypt(TEE_OperationHandle hndl, void *iv, uint32_t iv_siz
TEE_CipherInit(hndl, iv, iv_size);
LOGD("Cipher do final");
- size_t out_size_t;
+ size_t out_size_t = *output_size;
ret = TEE_CipherDoFinal(hndl, input, input_size, output, &out_size_t);
if (TEE_SUCCESS != ret) {
LOG("TEE_CipherDoFinal has failed with=%x.", ret);