Hi Raymond

Thanks for the detailed report. This issue was reported here  https://developer.trustedfirmware.org/T822 previously  but I didn’t get time to look into it further due to other priorities.  Your analysis seems right and I will look further into this.

 

Best Regards

Soby Mathew

 

From: TF-M <tf-m-bounces@lists.trustedfirmware.org> On Behalf Of Raymond Ngun via TF-M
Sent: 10 October 2020 00:59
To: tf-m@lists.trustedfirmware.org
Subject: [TF-M] Behavior difference in Crypto IPC vs Library modes

 

Hi all,

 

I’m seeking some assistance in determining the correct fix for a difference in behavior between IPC and Library modes that cause the Crypto PSA Arch Tests to fail when using IPC. Specifically, I’ve been testing on a PSoC64 for IPC mode and Musca-B1 for Library mode. The problem I am encountering is related to this check in crypto (e.g. crypto_aead.c in secure_fw/partitions/crypto).

 

    if ( !((in_len == 2) || (in_len == 3)) || (out_len > 1)) {

        return PSA_ERROR_CONNECTION_REFUSED;

    }

 

This is true for direct function call since in_len and out_len are sizes of in_vec[] and out_vec[]. However, in library mode, in_len and out_len is not based on the size of in_vec[] and out_vec[] but based on the contents.  Specifically, out_len is determined via the following in tfm_crypto_call_sfn().

 

    /* Check the number of out_vec filled */

    while ((out_len > 0) && (msg->out_size[out_len - 1] == 0)) {

        out_len--;

    }

 

From the above, if out_size (which is passed in by the user) is 0, the resultant out_len will be 0. The out_len is passed into the crypto function and PSA_ERROR_CONNECTION_REFUSED is returned due to the check above. PSA, on the other hand, expects PSA_ERROR_NOT_SUPPORTED to be returned. Btw, in_len suffers from the same issue.

 

I’m not sure if the check above is valid for IPC mode. I’ve removed the check temporarily to avoid the problem. However, if the check still makes sense, possibly it should return PSA_ERROR_NOT_SUPPORTED instead of PSA_ERROR_CONNECTION_REFUSED.

 

Thank you. I look forward to comments.

 

Ray

 

 


This message and any attachments may contain confidential information from Cypress or its subsidiaries. If it has been received in error, please advise the sender and immediately delete this message.