summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun Nie <jun.nie@linaro.org>2023-06-16 23:33:57 +0800
committerJun Nie <jun.nie@linaro.org>2023-06-16 23:51:55 +0800
commit5339856ea7e36f7d4e94017f5f46373484878915 (patch)
treeff44a398cbc0413d502e5cf5f01e64e5b1da14c6
parent2e0563e2527e6efd229c4af3be0798af8f529fa6 (diff)
TEE_CipherUpdate TEE_ERROR_SHORT_BUFFER in dedicate api
though enc/dec works in generate key api Signed-off-by: Jun Nie <jun.nie@linaro.org>
-rw-r--r--ta/key_demo/key_demo.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/ta/key_demo/key_demo.c b/ta/key_demo/key_demo.c
index 5d53c02..be0917d 100644
--- a/ta/key_demo/key_demo.c
+++ b/ta/key_demo/key_demo.c
@@ -592,15 +592,6 @@ EMSG("-----------Open persistent object, res=0x%08x", result);
goto cleanup2;
}
- /* check key object buf value */
- result = TEE_GetObjectBufferAttribute(key, TEE_ATTR_SECRET_VALUE, out, &out_size);
- if (result == TEE_SUCCESS) {
- EMSG("-----------get obj attr size %d, val[0] 0x%x val[8] 0x%x",
- out_size, out[0], out[8]);
- } else {
- EMSG("--------Failed to get attr: 0x%x", result);
- }
-
TEE_GetObjectInfo(key, &keyInfo3);
result = TEE_AllocateOperation(&encrypt_op, alg, mode,
@@ -626,8 +617,9 @@ EMSG("-----------Open persistent object, res=0x%08x", result);
TEE_CipherInit(encrypt_op, IV, IVlen);
- EMSG("========Input buf [0] %d [28] %d [108] %d.", in[0], in[28], in[108]);
- TEE_CipherUpdate(encrypt_op,
+ EMSG("========alg 0x%x mode 0x%x Input buf [0] %d [28] %d [108] %d.",
+ alg, mode, in[0], in[28], in[108]);
+ result = TEE_CipherUpdate(encrypt_op,
in, TEST_CRYPT_SIZE,
out, &out_size);
@@ -669,7 +661,7 @@ TEE_Result ta_key_demo_aes_process(uint32_t param_types, TEE_Param params[4])
TEE_MemMove(key_id, params[1].memref.buffer, params[1].memref.size);
TEE_MemMove(in_buf, params[2].memref.buffer, params[2].memref.size);
- TEE_MemFill(out_buf, 0, params[3].memref.size);
+ TEE_MemFill(out_buf, 0, params[2].memref.size);
EMSG("-----------Open persistent object, %s, id_len %d", key_id, params[1].memref.size);
ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
@@ -679,7 +671,7 @@ EMSG("-----------Open persistent object, %s, id_len %d", key_id, params[1].memre
result = internal_process(alg, mode, params[1].memref.size, key_id,
in_buf, out_buf);
if (result != TEE_SUCCESS) {
- EMSG("internal process fail : 0x%x", result);
+ EMSG("internal aes process fail : 0x%x", result);
goto cleanup1;
}
@@ -688,6 +680,8 @@ EMSG("-----------Open persistent object, %s, id_len %d", key_id, params[1].memre
cleanup1:
TEE_Free(key_id);
+
+ return TEE_SUCCESS;
}
TEE_Result ta_key_demo_create_key(uint32_t param_types,
@@ -777,10 +771,8 @@ TEE_Result ta_key_demo_create_key(uint32_t param_types,
goto cleanup2;
}
- /* reset output data before process */
- for (out_size = 0; out_size < TEST_CRYPT_SIZE; out_size++)
- in_buf[out_size] = 0;
-
+ EMSG("--------reset output buffer before decrypt");
+ TEE_MemFill(in_buf, 0, TEST_CRYPT_SIZE);
result = internal_process(alg, TEE_MODE_DECRYPT, key_id_sz, key_id,
out_buf, in_buf);
if (result != TEE_SUCCESS) {