Hi Ruchika,

You can pass multiple JSON files, identical except for the location value. So what you want to do is possible, but I agree that it is cumbersome. I've filed this as an enhancement request:
https://github.com/Mbed-TLS/mbedtls/issues/8371

Unfortunately at this point I don't know when we can deliver this. At this point, we are unlikely to work on driver code generation until after the 4.0 release.

Best regards,

--
Gilles Peskine
Mbed TLS developer and PSA Crypto architect

On 16/10/2023 15:38, Ruchika Gupta via mbed-tls wrote:

Hi,

 

For the crypto accelerator, we are developing for our SoC, we have a use-case where the same driver can support multiple/range of KEY LOCATIONS. We want a mechanism such that, the a common function in driver is called which can then take the necessary option based on the key location.

 

The way jsons are currently structured, what I understand is that for every key location, we will need to create a separate json with a different driver prefix. This would lead to a lot of code duplication for us.

 

For eg { to define 3 locations X, Y and Z , I need to create 3 json files -> these all refer to same crypto sub-system I my case}

 

#define TEST_DRIVER_X_OPAQUE_DRIVER_ID

#define TEST_DRIVER_Y_OPAQUE_DRIVER_ID

#define TEST_DRIVER_Z_OPAQUE_DRIVER_ID

 

Switch (key_location)

Case x:

                Test_driver_x_ opaque_import_key();

                break;

Case y:

                Test_driver_y_ opaque_import_key();

                break;

Case z:

                Test_driver_z_ opaque_import_key();

                break;

 

This is resulting in a lot of code duplication and overhead. What we want to have the flexibility to achieve is :

 

#define TEST_DRIVER_OPAQUE_DRIVER_ID

Switch (key_location)

Case x:

Case y:

Case z:

                Test_driver_opaque_import_key();

 

If we can support multiple locations from a driver json file for a given driver, this issue would be resolved. This would give the driver writers flexibility on how and where they want to handle the locations.

 

Please let us know your views on the same.

 

Regards,

Ruchika