linaro-swg / optee_examples

OP-TEE Sample Applications
Other
163 stars 140 forks source link

Failure in running optee_example_acipher - TEE_TYPE_RSA_KEYPAIR Not supported #109

Closed gunaMect closed 10 months ago

gunaMect commented 10 months ago

I am trying to run the optee_example_acipher example in my QEMU environment, but getting the below error

Client application logs:

optee_example_acipher optee_example_acipher: Unexpected number of arguments 0 (expected 2) usage: optee_example_acipher

optee_example_acipher 16 text-to-encrypt optee_example_acipher: TEEC_InvokeCommand(TA_ACIPHER_CMD_GEN_KEY): 0xffff000a (error origin 0x4)


Trusted application logs:

D/TC:? 0 tee_ta_init_pseudo_ta_session:299 Lookup pseudo TA a734eed9-d6a1-4244-aa50-7c99719e7b7b D/TC:? 0 ldelf_load_ldelf:91 ldelf load address 0x40006000 D/LD: ldelf:134 Loading TS a734eed9-d6a1-4244-aa50-7c99719e7b7b D/TC:? 0 ldelf_syscall_open_bin:142 Lookup user TA ELF a734eed9-d6a1-4244-aa50-7c99719e7b7b (Secure Storage TA) D/TC:? 0 ldelf_syscall_open_bin:146 res=0xffff0008 D/TC:? 0 ldelf_syscall_open_bin:142 Lookup user TA ELF a734eed9-d6a1-4244-aa50-7c99719e7b7b (REE) D/TC:? 0 ldelf_syscall_open_bin:146 res=0 D/LD: ldelf:168 ELF (a734eed9-d6a1-4244-aa50-7c99719e7b7b) at 0x40024000 E/TA: cmd_gen_key:35 TEE_AllocateTransientObject(0xa1000030, 16): 0xffff000a D/TC:? 0 tee_ta_invoke_command:823 Error: ffff000a of 4 D/TC:? 0 tee_ta_close_session:512 csess 0x14059c90 id 1 D/TC:? 0 tee_ta_close_session:531 Destroy session D/TC:? 0 destroy_context:308 Destroy TA ctx (0x14059c30)

On Analysing the source code, it is getting failed to generate RSA key pair -> https://github.com/linaro-swg/optee_examples/blob/378dc0db2d5dd279f58a3b6cb3f78ffd6b165035/acipher/ta/acipher_ta.c#L22

Here -> E/TA: cmd_gen_key:35 TEE_AllocateTransientObject(0xa1000030, 16): 0xffff000a Error code 0xffff000a indicates - TEE_ERROR_NOT_SUPPORTED and 0xa1000030 - TEE_TYPE_RSA_KEYPAIR from optee_os/lib/libutee/include.

Is the RSA_KEYPAIR generation not supported in QEMU environment. Can anyone help me resolve this issue? Thanks

etienne-lms commented 10 months ago

Argument is the the RSA private size expressed in bits. Try with 256, 384, etc...

gunaMect commented 10 months ago

Thanks @etienne-lms, it worked.

etienne-lms commented 10 months ago

@gunaMect, do you want to propose a patch in acipher/host/main.c to make helper message "usage: %s <key_size> <string to encrypt> more explicit about what refers to?