1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-28 00:21:48 +03:00

JSONschema and python improvements

* JSON Schema manually updated to be more semantically valid.
* Python script improved to be more verbose with exceptions
* Templating file improved by adding an additional macro.

Signed-off-by: Archana <archana.madhavan@silabs.com>
Signed-off-by: Asfandyar Orakzai <asfandyar.orakzai@silabs.com>
This commit is contained in:
Archana
2022-02-27 05:38:55 +05:30
committed by Asfandyar Orakzai
parent e17071a5ee
commit fdbbcba3eb
8 changed files with 176 additions and 185 deletions

View File

@ -1,13 +1,16 @@
{# One Shot function's dispatch code for opaque drivers.
Expected inputs:
* drivers: the list of driver descriptions.
* entry_point: the name of the entry point that this function dispatches to.
* entry_point_param(driver): the parameters to pass to the entry point.
* nest_indent: number of extra spaces to indent the code to.
-#}
{% for driver in drivers if driver.type == "opaque" -%}
{% for capability in driver.capabilities if entry_point in capability.entry_points -%}
#if ({% if capability.depend_on is defined -%}{{ capability.depend_on }} {% else -%} {{ 1 }} {% endif %})
#if ({% if capability['mbedtls/c_depend_on'] is defined -%}{{ capability['mbedtls/c_depend_on'] }} {% else -%} {{ 1 }} {% endif %})
{%- filter indent(width = nest_indent) %}
case {{ driver.location }}:
{% if capability.name is defined and entry_point in capability.name.keys() -%}
return({{ capability.name[entry_point]}}({{entry_point_attributes(driver) | indent(20)}}));
{% else -%}
return({{driver.prefix}}_{{driver.type}}_{{entry_point}}({{entry_point_attributes(driver) | indent(20)}}));
{% endif -%}
return( {{ entry_point_name(capability, entry_point, driver) }}({{entry_point_param(driver) | indent(20)}}));
{% endfilter -%}
#endif
{% endfor %}

View File

@ -1,12 +1,15 @@
{# One Shot function's dispatch code for transparent drivers.
Expected inputs:
* drivers: the list of driver descriptions.
* entry_point: the name of the entry point that this function dispatches to.
* entry_point_param(driver): the parameters to pass to the entry point.
* nest_indent: number of extra spaces to indent the code to.
-#}
{% for driver in drivers if driver.type == "transparent" -%}
{% for capability in driver.capabilities if entry_point in capability.entry_points -%}
#if ({% if capability.depend_on is defined -%}{{ capability.depend_on }} {% else -%} {{ 1 }} {% endif %})
#if ({% if capability['mbedtls/c_depend_on'] is defined -%}{{ capability['mbedtls/c_depend_on'] }} {% else -%} {{ 1 }} {% endif %})
{%- filter indent(width = nest_indent) %}
{% if capability.name is defined and entry_point in capability.name.keys() -%}
status = {{ capability.name[entry_point]}}({{entry_point_attributes(driver) | indent(20)}});
{% else -%}
status = {{driver.prefix}}_{{driver.type}}_{{entry_point}}({{entry_point_attributes(driver) | indent(20)}});
{% endif -%}
status = {{ entry_point_name(capability, entry_point, driver) }}({{entry_point_param(driver) | indent(20)}});
if( status != PSA_ERROR_NOT_SUPPORTED )
return( status );

View File

@ -1,7 +1,7 @@
/*
* Functions to delegate cryptographic operations to an available
* and appropriate accelerator.
* Warning: This file will be auto-generated in the future.
* Warning: This file is now auto-generated.
*/
/* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0
@ -39,13 +39,15 @@
#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS)
{% for driver in drivers -%}
/* Headers for {{driver.prefix}} {{driver.type}} driver */
{% if driver.dependency is defined -%}
#if {{ driver.dependency }}
{% if driver['mbedtls/h_depend_on'] is defined -%}
#if {{ driver['mbedtls/h_depend_on'] }}
{% endif -%}
{% for header in driver.headers -%}
#include "{{ header }}"
{% endfor %}
{% if driver['mbedtls/h_depend_on'] is defined -%}
#endif
{% endif -%}
{% endfor %}
#endif /* MBEDTLS_PSA_CRYPTO_DRIVERS */
/* END-driver headers */
@ -60,6 +62,16 @@
{% endfor %}
/* END-driver id */
/* BEGIN-Common Macro definitions */
{% macro entry_point_name(capability, entry_point, driver) -%}
{% if capability.name is defined and entry_point in capability.name.keys() -%}
{{ capability.name[entry_point]}}
{% else -%}
{{driver.prefix}}_{{driver.type}}_{{entry_point}}
{% endif -%}
{% endmacro %}
/* END-Common Macro definitions */
/* Support the 'old' SE interface when asked to */
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
/* PSA_CRYPTO_DRIVER_PRESENT is defined when either a new-style or old-style
@ -595,7 +607,7 @@ psa_status_t psa_driver_wrapper_import_key(
size_t *bits )
{
{% set entry_point = "import_key" -%}
{% macro entry_point_attributes(driver) -%}
{% macro entry_point_param(driver) -%}
attributes,
data,
data_length,
@ -677,7 +689,7 @@ psa_status_t psa_driver_wrapper_export_key(
{
{% set entry_point = "export_key" -%}
{% macro entry_point_attributes(driver) -%}
{% macro entry_point_param(driver) -%}
attributes,
key_buffer,
key_buffer_size,
@ -740,7 +752,7 @@ psa_status_t psa_driver_wrapper_export_public_key(
{
{% set entry_point = "export_public_key" -%}
{% macro entry_point_attributes(driver) -%}
{% macro entry_point_param(driver) -%}
attributes,
key_buffer,
key_buffer_size,
@ -812,7 +824,7 @@ psa_status_t psa_driver_wrapper_get_builtin_key(
uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length )
{
{% set entry_point = "get_builtin_key" -%}
{% macro entry_point_attributes(driver) -%}
{% macro entry_point_param(driver) -%}
slot_number,
attributes,
key_buffer,
@ -845,7 +857,7 @@ psa_status_t psa_driver_wrapper_copy_key(
size_t *target_key_buffer_length )
{
{% set entry_point = "copy_key" -%}
{% macro entry_point_attributes(driver) -%}
{% macro entry_point_param(driver) -%}
attributes,
source_key,
source_key_length,