aes : Add fix to read correct value from ram address for derive_aes_256_key cmd

Change-Id: I0e3080b641b3b050655fdbb626273ec14cbc6aa2
Signed-off-by: Poovendhan Selvaraj <quic_poovendh@quicinc.com>
This commit is contained in:
Poovendhan Selvaraj 2023-08-03 19:28:07 +05:30
parent 91b4536719
commit 363824c036

View file

@ -118,15 +118,13 @@ static int do_derive_aes_256_key(cmd_tbl_t *cmdtp, int flag,
struct crypto_aes_derive_key_cmd_t *req_ptr = NULL; struct crypto_aes_derive_key_cmd_t *req_ptr = NULL;
int ret = CMD_RET_USAGE; int ret = CMD_RET_USAGE;
uintptr_t *key_handle = NULL; uintptr_t *key_handle = NULL;
char *context_buf = NULL; uint8_t *context_buf = NULL;
int context_len = 0; int context_len = 0;
int i = 0, j = 0; int i = 0, j = 0;
unsigned char temp;
if (argc != 5) if (argc != 5)
return ret; return ret;
context_buf = (uint8_t *)simple_strtoul(argv[3], NULL, 16);;
context_buf = argv[3];
context_len = simple_strtoul(argv[4], NULL, 16); context_len = simple_strtoul(argv[4], NULL, 16);
if (context_len > 64) { if (context_len > 64) {
printf("Error: context length should be less than 64\n"); printf("Error: context length should be less than 64\n");
@ -142,19 +140,14 @@ static int do_derive_aes_256_key(cmd_tbl_t *cmdtp, int flag,
req_ptr->policy.key_type = DEFAULT_KEY_TYPE; req_ptr->policy.key_type = DEFAULT_KEY_TYPE;
req_ptr->policy.destination = DEFAULT_POLICY_DESTINATION; req_ptr->policy.destination = DEFAULT_POLICY_DESTINATION;
req_ptr->source = simple_strtoul(argv[1], NULL, 16); req_ptr->source = simple_strtoul(argv[1], NULL, 16);
req_ptr->hw_key_bindings.bindings = simple_strtoul(argv[2], NULL, 16);; req_ptr->hw_key_bindings.bindings = simple_strtoul(argv[2], NULL, 16);
key_handle = (uintptr_t *)memalign(ARCH_DMA_MINALIGN, key_handle = (uintptr_t *)memalign(ARCH_DMA_MINALIGN,
sizeof(uint64_t)); sizeof(uint64_t));
req_ptr->key = (uintptr_t) key_handle; req_ptr->key = (uintptr_t) key_handle;
req_ptr->mixing_key = 0; req_ptr->mixing_key = 0;
req_ptr->hw_key_bindings.context_len = context_len; req_ptr->hw_key_bindings.context_len = context_len;
while (i < context_len) {
while(context_buf[i] != '\0' && i < context_len*2) { req_ptr->hw_key_bindings.context[j++] = context_buf[i++];
temp = toBinary(context_buf[i]) << 4;
temp += toBinary(context_buf[i+1]);
req_ptr->hw_key_bindings.context[j] = temp;
j++;
i += 2;
} }
ret = qca_scm_crypto(TZ_CRYPTO_SERVICE_AES_DERIVE_KEY_ID, (void *)req_ptr, ret = qca_scm_crypto(TZ_CRYPTO_SERVICE_AES_DERIVE_KEY_ID, (void *)req_ptr,
sizeof(struct crypto_aes_derive_key_cmd_t)); sizeof(struct crypto_aes_derive_key_cmd_t));