blob: 84c311ca59aed2c38b416f3d1c7c757edcc7663f [file] [log] [blame] [view]
Dave Rodgman017a1992022-03-31 14:07:01 +01001Migrating to an auto generated psa_crypto_driver_wrappers.c file
2================================================================
Archana1f1a34a2021-11-17 08:44:07 +05303
4**This is a specification of work in progress. The implementation is not yet merged into Mbed TLS.**
Manuel Pégourié-Gonnardde24ba62023-08-07 11:36:14 +02005For a description of the current state of drivers Mbed TLS, see our [PSA Cryptoprocessor driver development examples](../psa-driver-example-and-guide.html).
Archana1f1a34a2021-11-17 08:44:07 +05306
7This document describes how to migrate to the auto generated psa_crypto_driver_wrappers.c file.
8It 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.
9
10## Introduction
11
Dave Rodgman017a1992022-03-31 14:07:01 +010012The design of the Driver Wrappers code generation is based on the design proposal https://github.com/Mbed-TLS/mbedtls/pull/5067
Archana1f1a34a2021-11-17 08:44:07 +053013During the process of implementation there might be minor variations wrt versioning and broader implementation specific ideas, but the design remains the same.
14
15## Prerequisites
16
Archana46886242022-03-13 19:49:11 +053017Python3, Jinja2 rev 2.10.1 and jsonschema rev 3.2.0
Archana1f1a34a2021-11-17 08:44:07 +053018
19## Feature Version
20
Archana46886242022-03-13 19:49:11 +0530211.1
Archana1f1a34a2021-11-17 08:44:07 +053022
23### What's critical for a migrating user
24
Tom Cosgrove0b86ac12022-07-29 13:44:01 +010025The 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).
Archana1f1a34a2021-11-17 08:44:07 +053026
Archana46886242022-03-13 19:49:11 +053027While that is the larger goal, for version 1.1 here's what's changed
Archana1f1a34a2021-11-17 08:44:07 +053028
29#### What's changed
30
31(1) psa_crypto_driver_wrappers.c will from this point on be auto generated.
Archana46886242022-03-13 19:49:11 +053032(2) The auto generation is based on the template file at **scripts/data_files/driver_templates/psa_crypto_driver_wrappers.c.jinja**.
33(3) The driver JSONS to be used for generating the psa_crypto_driver_wrappers.c 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.
Archana1776dd92022-04-12 13:12:18 +053034(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.c file, the user will need to patch into the template file as needed (psa_crypto_driver_wrappers.c.jinja).
Archana46886242022-03-13 19:49:11 +053035
36#### How to set your driver up
37
38Please refer to psa-driver-interface.md for information on how a driver schema can be written.
39One can also refer to the example test drivers/ JSON schemas under **scripts/data_files/driver_jsons/**.
40
Archana1776dd92022-04-12 13:12:18 +053041The 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.