1a8e1175bSopenharmony_ciMigrating to an auto generated psa_crypto_driver_wrappers.h file 2a8e1175bSopenharmony_ci================================================================ 3a8e1175bSopenharmony_ci 4a8e1175bSopenharmony_ciThis document describes how to migrate to the auto generated psa_crypto_driver_wrappers.h file. 5a8e1175bSopenharmony_ciIt is meant to give the library user migration guidelines while the Mbed TLS project tides over multiple minor revs of version 1.0, after which this will be merged into psa-driver-interface.md. 6a8e1175bSopenharmony_ci 7a8e1175bSopenharmony_ciFor a practical guide with a description of the current state of drivers Mbed TLS, see our [PSA Cryptoprocessor driver development examples](../psa-driver-example-and-guide.md). 8a8e1175bSopenharmony_ci 9a8e1175bSopenharmony_ci## Introduction 10a8e1175bSopenharmony_ci 11a8e1175bSopenharmony_ciThe design of the Driver Wrappers code generation is based on the design proposal https://github.com/Mbed-TLS/mbedtls/pull/5067 12a8e1175bSopenharmony_ciDuring the process of implementation there might be minor variations wrt versioning and broader implementation specific ideas, but the design remains the same. 13a8e1175bSopenharmony_ci 14a8e1175bSopenharmony_ci## Prerequisites 15a8e1175bSopenharmony_ci 16a8e1175bSopenharmony_ciPython3, Jinja2 rev 2.10.1 and jsonschema rev 3.2.0 17a8e1175bSopenharmony_ci 18a8e1175bSopenharmony_ci## Feature Version 19a8e1175bSopenharmony_ci 20a8e1175bSopenharmony_ci1.1 21a8e1175bSopenharmony_ci 22a8e1175bSopenharmony_ci### What's critical for a migrating user 23a8e1175bSopenharmony_ci 24a8e1175bSopenharmony_ciThe Driver Wrapper auto generation project is designed to use a python templating library ( Jinja2 ) to render templates based on drivers that are defined using a Driver description JSON file(s). 25a8e1175bSopenharmony_ci 26a8e1175bSopenharmony_ciWhile that is the larger goal, for version 1.1 here's what's changed 27a8e1175bSopenharmony_ci 28a8e1175bSopenharmony_ci#### What's changed 29a8e1175bSopenharmony_ci 30a8e1175bSopenharmony_ci(1) psa_crypto_driver_wrappers.h will from this point on be auto generated. 31a8e1175bSopenharmony_ci(2) The auto generation is based on the template file at **scripts/data_files/driver_templates/psa_crypto_driver_wrappers.h.jinja**. 32a8e1175bSopenharmony_ci(3) The driver JSONS to be used for generating the psa_crypto_driver_wrappers.h file can be found at **scripts/data_files/driver_jsons/** as their default location, this path includes the schemas against which the driver schemas will be validated (driver_opaque_schema.json, driver_transparent_schema.json) and a driverlist.json which specifies the drivers to be considered and the order in which they want to be called into. The default location for driverlist.json and driver JSONS can be overloaded by passing an argument --json-dir while running the script generate_driver_wrappers.py. 33a8e1175bSopenharmony_ci(4) While the complete driver wrapper templating support is yet to come in, if the library user sees a need to patch psa_crypto_driver_wrappers.h file, the user will need to patch into the template file as needed (psa_crypto_driver_wrappers.h.jinja). 34a8e1175bSopenharmony_ci 35a8e1175bSopenharmony_ci#### How to set your driver up 36a8e1175bSopenharmony_ci 37a8e1175bSopenharmony_ciPlease refer to psa-driver-interface.md for information on how a driver schema can be written. 38a8e1175bSopenharmony_ciOne can also refer to the example test drivers/ JSON schemas under **scripts/data_files/driver_jsons/**. 39a8e1175bSopenharmony_ci 40a8e1175bSopenharmony_ciThe JSON file 'driverlist.json' is meant to be edited by the user to reflect the drivers one wants to use on a device. The order in which the drivers are passed is also essential if/when there are multiple transparent drivers on a given system to retain the same order in the templating. 41