Skip to content

Commit ecfd050

Browse files
authored
Merge pull request #230 from AndrzejKurek/remove-double-underscore
Remove double underscores from macro and add a check for it
2 parents 89e7655 + 712f7a8 commit ecfd050

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

include/psa/crypto_values.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -1015,15 +1015,15 @@
10151015
* \return The corresponding AEAD algorithm with the default
10161016
* tag length for that algorithm.
10171017
*/
1018-
#define PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH(aead_alg) \
1019-
( \
1020-
PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE(aead_alg, PSA_ALG_CCM) \
1021-
PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE(aead_alg, PSA_ALG_GCM) \
1022-
PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE(aead_alg, PSA_ALG_CHACHA20_POLY1305) \
1018+
#define PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH(aead_alg) \
1019+
( \
1020+
PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH_CASE(aead_alg, PSA_ALG_CCM) \
1021+
PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH_CASE(aead_alg, PSA_ALG_GCM) \
1022+
PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH_CASE(aead_alg, PSA_ALG_CHACHA20_POLY1305) \
10231023
0)
1024-
#define PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE(aead_alg, ref) \
1025-
PSA_ALG_AEAD_WITH_TAG_LENGTH(aead_alg, 0) == \
1026-
PSA_ALG_AEAD_WITH_TAG_LENGTH(ref, 0) ? \
1024+
#define PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH_CASE(aead_alg, ref) \
1025+
PSA_ALG_AEAD_WITH_TAG_LENGTH(aead_alg, 0) == \
1026+
PSA_ALG_AEAD_WITH_TAG_LENGTH(ref, 0) ? \
10271027
ref :
10281028

10291029
#define PSA_ALG_RSA_PKCS1V15_SIGN_BASE ((psa_algorithm_t)0x10020000)

tests/scripts/check-names.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,14 @@ for THING in actual-macros enum-consts; do
5757
printf "Names of $THING: "
5858
test -r $THING
5959
BAD=$( grep -E -v '^(MBEDTLS|PSA)_[0-9A-Z_]*[0-9A-Z]$' $THING || true )
60-
if [ "x$BAD" = "x" ]; then
60+
UNDERSCORES=$( grep -E '.*__.*' $THING || true )
61+
62+
if [ "x$BAD" = "x" ] && [ "x$UNDERSCORES" = "x" ]; then
6163
echo "PASS"
6264
else
6365
echo "FAIL"
6466
echo "$BAD"
67+
echo "$UNDERSCORES"
6568
FAIL=1
6669
fi
6770
done

tests/scripts/test_psa_constant_names.py

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def _argument_split(cls, arguments):
162162
# PSA_ALG_ECDH and PSA_ALG_FFDH are excluded for now as the script
163163
# currently doesn't support them. Deprecated errors are also excluded.
164164
_excluded_names = set(['PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH',
165+
'PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH_CASE',
165166
'PSA_ALG_FULL_LENGTH_MAC',
166167
'PSA_ALG_ECDH',
167168
'PSA_ALG_FFDH',

0 commit comments

Comments
 (0)