Allocate destData buffer with expected output size 01/297401/3
authorDongsun Lee <ds73.lee@samsung.com>
Thu, 17 Aug 2023 08:20:36 +0000 (17:20 +0900)
committerDong Sun Lee <ds73.lee@samsung.com>
Mon, 4 Sep 2023 23:44:15 +0000 (23:44 +0000)
- TEE_AEEncryptFinal() doesn't guarantee that it allows NULL destData
  for getting destLen.

Change-Id: Ic7205462e3b5cf2cef84e17c3285b76c3ab24006

ta/src/internal.c

index e5d1c3399282183423e6282487134c5259906cff..d292132435ca9162766112fd32473042f813aa51 100644 (file)
@@ -311,14 +311,7 @@ TEE_Result KM_EncryptBinary(const KM_PwdData *pwd, KM_BinaryData *input,
                goto clean;
        }
 
-       ret = KM_EncryptDataWithPwd(pwd, input->data, input->data_size,
-                               output->data, &output->data_size, tag->data, &tag->data_size);
-       if (ret != TEE_ERROR_SHORT_BUFFER && ret != TEE_SUCCESS) {
-               LOG("Failed to probe for needed data size");
-               ret = TEE_ERROR_GENERIC;
-               goto clean;
-       }
-
+       output->data_size = input->data_size;
        output->data = TEE_Malloc(output->data_size, 0);
        if (output->data == NULL) {
                LOG("Failed to allocate object buffer for encrypting data");