From d3ce75c5f9bb03cb0a6432adc98ee9396ffacac1 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 4 Jan 2023 19:50:27 +0100 Subject: [PATCH 1/2] Skip restyling of PSA error code definitions Some preprocessor macro definitions must have a specific expansion so that the same macro name can be defined in different products. The definition of having the same expansion (per the C language specification) means the same sequence of tokens, and also the same absence/presence of spacing between tokens. For PSA error code definitions, the specific expansion is mandated by the PSA Status code specification and the PSA Crypto API specification. In particular, there must not be a space between (psa_status_t) and the numerical value (whereas K&R would put a space). Signed-off-by: Gilles Peskine --- include/psa/crypto_values.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/psa/crypto_values.h b/include/psa/crypto_values.h index 4df4fe4350..45c16b0a05 100644 --- a/include/psa/crypto_values.h +++ b/include/psa/crypto_values.h @@ -57,6 +57,13 @@ * value, check with the Arm PSA framework group to pick one that other * domains aren't already using. */ +/* Tell uncrustify not to touch the constant definitions, otherwise + * it might change the spacing to something that is not PSA-compliant + * (e.g. adding a space after casts). + * + * *INDENT-OFF* + */ + /** The action was completed successfully. */ #define PSA_SUCCESS ((psa_status_t)0) @@ -327,6 +334,8 @@ */ #define PSA_ERROR_DATA_INVALID ((psa_status_t)-153) +/* *INDENT-ON* */ + /**@}*/ /** \defgroup crypto_types Key and algorithm types From 7f3659a7130aef293093826789eccc91ce8a9f55 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 4 Jan 2023 19:52:38 +0100 Subject: [PATCH 2/2] Skip restyling of PSA macros also defined in psa-arch-tests Some preprocessor macro definitions must have a specific expansion so that the same macro name can be defined in different products. The definition of having the same expansion (per the C language specification) means the same sequence of tokens, and also the same absence/presence of spacing between tokens. Two macros are also defined in headers in the PSA Compliance test suite, so the test suite would fail to build if we changed the definitions. Preserve those definitions. Technically this is a bug in the test suite, since having extra spaces (or even a completely different constant expression with the same value) would still be compliant. Bug reported as https://github.com/ARM-software/psa-arch-tests/issues/337 Signed-off-by: Gilles Peskine --- include/psa/crypto_values.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/psa/crypto_values.h b/include/psa/crypto_values.h index 45c16b0a05..a9fddb7976 100644 --- a/include/psa/crypto_values.h +++ b/include/psa/crypto_values.h @@ -828,7 +828,9 @@ (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_DERIVATION) /** An invalid algorithm identifier value. */ +/* *INDENT-OFF* (https://github.com/ARM-software/psa-arch-tests/issues/337) */ #define PSA_ALG_NONE ((psa_algorithm_t)0) +/* *INDENT-ON* */ #define PSA_ALG_HASH_MASK ((psa_algorithm_t)0x000000ff) /** MD2 */ @@ -2094,7 +2096,9 @@ /** The null key identifier. */ +/* *INDENT-OFF* (https://github.com/ARM-software/psa-arch-tests/issues/337) */ #define PSA_KEY_ID_NULL ((psa_key_id_t)0) +/* *INDENT-ON* */ /** The minimum value for a key identifier chosen by the application. */ #define PSA_KEY_ID_USER_MIN ((psa_key_id_t)0x00000001)