Skip to content

Commit 1726775

Browse files
Merge pull request #236 from gilles-peskine-arm/build_info-cleanup-1.0-framework
Clean up after 1.0: generate_config_checks.py, tf-psa-crypto/build_info.h
2 parents 6c9076e + d6f03a4 commit 1726775

File tree

6 files changed

+78
-138
lines changed

6 files changed

+78
-138
lines changed

history/config-adjust-tfpsacrypto-1.0.txt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ MBEDTLS_CIPHER_PADDING_PKCS7
3232
MBEDTLS_CMAC_C
3333
MBEDTLS_CONFIG_ADJUST_LEGACY_CRYPTO_H
3434
MBEDTLS_CONFIG_ADJUST_LEGACY_FROM_PSA_H
35-
MBEDTLS_CONFIG_ADJUST_PSA_SUPERSET_LEGACY_H
3635
MBEDTLS_CONFIG_ADJUST_TEST_ACCELERATORS_H
37-
MBEDTLS_DES_C
3836
MBEDTLS_ECDH_C
3937
MBEDTLS_ECDSA_C
4038
MBEDTLS_ECDSA_DETERMINISTIC
@@ -127,7 +125,6 @@ MBEDTLS_PSA_ACCEL_KEY_TYPE_ARIA
127125
MBEDTLS_PSA_ACCEL_KEY_TYPE_CAMELLIA
128126
MBEDTLS_PSA_ACCEL_KEY_TYPE_CHACHA20
129127
MBEDTLS_PSA_ACCEL_KEY_TYPE_DERIVE
130-
MBEDTLS_PSA_ACCEL_KEY_TYPE_DES
131128
MBEDTLS_PSA_ACCEL_KEY_TYPE_DH_KEY_PAIR_BASIC
132129
MBEDTLS_PSA_ACCEL_KEY_TYPE_DH_KEY_PAIR_EXPORT
133130
MBEDTLS_PSA_ACCEL_KEY_TYPE_DH_KEY_PAIR_GENERATE
@@ -211,7 +208,6 @@ MBEDTLS_PSA_BUILTIN_KEY_TYPE_AES
211208
MBEDTLS_PSA_BUILTIN_KEY_TYPE_ARIA
212209
MBEDTLS_PSA_BUILTIN_KEY_TYPE_CAMELLIA
213210
MBEDTLS_PSA_BUILTIN_KEY_TYPE_CHACHA20
214-
MBEDTLS_PSA_BUILTIN_KEY_TYPE_DES
215211
MBEDTLS_PSA_BUILTIN_KEY_TYPE_DH_KEY_PAIR_BASIC
216212
MBEDTLS_PSA_BUILTIN_KEY_TYPE_DH_KEY_PAIR_EXPORT
217213
MBEDTLS_PSA_BUILTIN_KEY_TYPE_DH_KEY_PAIR_GENERATE
@@ -235,7 +231,6 @@ MBEDTLS_PSA_CRYPTO_RNG_STRENGTH
235231
MBEDTLS_PSA_DH_ACCEL_INCOMPLETE_ALGS
236232
MBEDTLS_PSA_DH_ACCEL_INCOMPLETE_GROUPS
237233
MBEDTLS_PSA_DH_ACCEL_INCOMPLETE_KEY_TYPES
238-
MBEDTLS_PSA_DRIVER_GET_ENTROPY
239234
MBEDTLS_PSA_DRIVER_GET_ENTROPY_DEFINED
240235
MBEDTLS_PSA_ECC_ACCEL_INCOMPLETE_ALGS
241236
MBEDTLS_PSA_ECC_ACCEL_INCOMPLETE_CURVES
@@ -247,8 +242,6 @@ MBEDTLS_RSA_C
247242
MBEDTLS_SHA1_C
248243
MBEDTLS_SHA224_C
249244
MBEDTLS_SHA256_C
250-
MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
251-
MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY
252245
MBEDTLS_SHA384_C
253246
MBEDTLS_SHA512_C
254247
MBEDTLS_SSL_HAVE_AEAD
@@ -266,7 +259,6 @@ PSA_HAVE_SOFT_BLOCK_MODE
266259
PSA_HAVE_SOFT_KEY_TYPE_AES
267260
PSA_HAVE_SOFT_KEY_TYPE_ARIA
268261
PSA_HAVE_SOFT_KEY_TYPE_CAMELLIA
269-
PSA_HAVE_SOFT_KEY_TYPE_DES
270262
PSA_HAVE_SOFT_PBKDF2
271263
PSA_HAVE_SOFT_PBKDF2_CMAC
272264
PSA_HAVE_SOFT_PBKDF2_HMAC
@@ -275,29 +267,11 @@ PSA_WANT_ALG_ECB_NO_PADDING
275267
PSA_WANT_ALG_ECDSA
276268
PSA_WANT_ALG_ECDSA_ANY
277269
PSA_WANT_ALG_HMAC
278-
PSA_WANT_ALG_MD5
279-
PSA_WANT_ALG_RIPEMD160
280270
PSA_WANT_ALG_RSA_PKCS1V15_SIGN
281271
PSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW
282272
PSA_WANT_ALG_RSA_PSS
283273
PSA_WANT_ALG_RSA_PSS_ANY_SALT
284-
PSA_WANT_ALG_SHA_1
285-
PSA_WANT_ALG_SHA_224
286-
PSA_WANT_ALG_SHA_256
287-
PSA_WANT_ALG_SHA_384
288-
PSA_WANT_ALG_SHA_512
289274
PSA_WANT_ALG_SOME_PAKE
290-
PSA_WANT_ECC_BRAINPOOL_P_R1_256
291-
PSA_WANT_ECC_BRAINPOOL_P_R1_384
292-
PSA_WANT_ECC_BRAINPOOL_P_R1_512
293-
PSA_WANT_ECC_MONTGOMERY_255
294-
PSA_WANT_ECC_MONTGOMERY_448
295-
PSA_WANT_ECC_SECP_K1_192
296-
PSA_WANT_ECC_SECP_K1_256
297-
PSA_WANT_ECC_SECP_R1_192
298-
PSA_WANT_ECC_SECP_R1_256
299-
PSA_WANT_ECC_SECP_R1_384
300-
PSA_WANT_ECC_SECP_R1_521
301275
PSA_WANT_KEY_TYPE_AES
302276
PSA_WANT_KEY_TYPE_DERIVE
303277
PSA_WANT_KEY_TYPE_DH_KEY_PAIR_BASIC

history/config-options-mbedtls-4.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
4040
MBEDTLS_SSL_KEYING_MATERIAL_EXPORT
4141
MBEDTLS_SSL_MAX_EARLY_DATA_SIZE
4242
MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
43+
MBEDTLS_SSL_NULL_CIPHERSUITES
4344
MBEDTLS_SSL_OUT_CONTENT_LEN
4445
MBEDTLS_SSL_PROTO_DTLS
4546
MBEDTLS_SSL_PROTO_TLS1_2

history/config-options-tfpsacrypto-1.0.txt

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,14 @@ MBEDTLS_AES_USE_HARDWARE_ONLY
77
MBEDTLS_ASN1_PARSE_C
88
MBEDTLS_ASN1_WRITE_C
99
MBEDTLS_BASE64_C
10-
MBEDTLS_BIGNUM_C
1110
MBEDTLS_BLOCK_CIPHER_NO_DECRYPT
1211
MBEDTLS_CAMELLIA_SMALL_MEMORY
1312
MBEDTLS_CHECK_RETURN
1413
MBEDTLS_CHECK_RETURN_WARNING
15-
MBEDTLS_CIPHER_NULL_CIPHER
1614
MBEDTLS_CTR_DRBG_C
1715
MBEDTLS_DEPRECATED_REMOVED
1816
MBEDTLS_DEPRECATED_WARNING
19-
MBEDTLS_ECDH_C
2017
MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
21-
MBEDTLS_ECDSA_C
22-
MBEDTLS_ECJPAKE_C
23-
MBEDTLS_ECP_C
24-
MBEDTLS_ECP_DP_BP256R1_ENABLED
25-
MBEDTLS_ECP_DP_BP384R1_ENABLED
26-
MBEDTLS_ECP_DP_BP512R1_ENABLED
27-
MBEDTLS_ECP_DP_CURVE25519_ENABLED
28-
MBEDTLS_ECP_DP_CURVE448_ENABLED
29-
MBEDTLS_ECP_DP_SECP192K1_ENABLED
30-
MBEDTLS_ECP_DP_SECP192R1_ENABLED
31-
MBEDTLS_ECP_DP_SECP256K1_ENABLED
32-
MBEDTLS_ECP_DP_SECP256R1_ENABLED
33-
MBEDTLS_ECP_DP_SECP384R1_ENABLED
34-
MBEDTLS_ECP_DP_SECP521R1_ENABLED
3518
MBEDTLS_ECP_FIXED_POINT_OPTIM
3619
MBEDTLS_ECP_NIST_OPTIM
3720
MBEDTLS_ECP_RESTARTABLE
@@ -74,7 +57,6 @@ MBEDTLS_PLATFORM_EXIT_MACRO
7457
MBEDTLS_PLATFORM_FPRINTF_ALT
7558
MBEDTLS_PLATFORM_FPRINTF_MACRO
7659
MBEDTLS_PLATFORM_FREE_MACRO
77-
MBEDTLS_PLATFORM_GET_ENTROPY_ALT
7860
MBEDTLS_PLATFORM_GMTIME_R_ALT
7961
MBEDTLS_PLATFORM_MEMORY
8062
MBEDTLS_PLATFORM_MS_TIME_ALT
@@ -136,8 +118,6 @@ MBEDTLS_RSA_GEN_KEY_MIN_BITS
136118
MBEDTLS_RSA_NO_CRT
137119
MBEDTLS_SELF_TEST
138120
MBEDTLS_SHA256_SMALLER
139-
MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT
140-
MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY
141121
MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
142122
MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY
143123
MBEDTLS_SHA512_SMALLER
@@ -212,14 +192,12 @@ PSA_WANT_KEY_TYPE_ARIA
212192
PSA_WANT_KEY_TYPE_CAMELLIA
213193
PSA_WANT_KEY_TYPE_CHACHA20
214194
PSA_WANT_KEY_TYPE_DERIVE
215-
PSA_WANT_KEY_TYPE_DES
216195
PSA_WANT_KEY_TYPE_DH_KEY_PAIR_BASIC
217196
PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE
218197
PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT
219198
PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE
220199
PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT
221200
PSA_WANT_KEY_TYPE_DH_PUBLIC_KEY
222-
PSA_WANT_KEY_TYPE_ECC_KEY_PAIR
223201
PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC
224202
PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE
225203
PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT
@@ -230,13 +208,14 @@ PSA_WANT_KEY_TYPE_HMAC
230208
PSA_WANT_KEY_TYPE_PASSWORD
231209
PSA_WANT_KEY_TYPE_PASSWORD_HASH
232210
PSA_WANT_KEY_TYPE_RAW_DATA
233-
PSA_WANT_KEY_TYPE_RSA_KEY_PAIR
234211
PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC
235212
PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE
236213
PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT
237214
PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE
238215
PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT
239216
PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY
217+
TF_PSA_CRYPTO_ALLOW_REMOVED_MECHANISMS
240218
TF_PSA_CRYPTO_CONFIG_FILE
219+
TF_PSA_CRYPTO_CONFIG_VERSION
241220
TF_PSA_CRYPTO_USER_CONFIG_FILE
242221
TF_PSA_CRYPTO_VERSION

scripts/check_names.py

Lines changed: 64 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ class Problem(abc.ABC): # pylint: disable=too-few-public-methods
9999
# Class variable to control the quietness of all problems
100100
quiet = False
101101
def __init__(self):
102-
self.textwrapper = textwrap.TextWrapper()
102+
self.textwrapper = textwrap.TextWrapper(break_on_hyphens=False,
103+
break_long_words=False)
103104
self.textwrapper.width = 80
104105
self.textwrapper.initial_indent = " > "
105106
self.textwrapper.subsequent_indent = " "
@@ -288,7 +289,16 @@ def get_all_files(self, include_wildcards, exclude_wildcards):
288289
289290
Args:
290291
* include_wildcards: a List of shell-style wildcards to match filepaths.
292+
- "*" does not match a directory separator, e.g. "*/a.h"
293+
matches "somedir/a.h" but not "somedir/subdir/a.h".
294+
- "**" matches zero or more directory levels, e.g. "**/a.h"
295+
matches "a.h", "somedir/a.h", "somedir/subdir/a.h", etc.
296+
- The matching is case-insensitive.
291297
* exclude_wildcards: a List of shell-style wildcards to exclude.
298+
- "*" matches every character including separators, e.g. "*/a.h"
299+
matches "somedir/a.h" and "somedir/subdir/a.h" but not "a.h".
300+
- "**" is equivalent to "*".
301+
- The matching is case-sensitive.
292302
293303
Returns:
294304
* inc_files: A List of relative filepaths for included files.
@@ -297,7 +307,7 @@ def get_all_files(self, include_wildcards, exclude_wildcards):
297307
accumulator = set()
298308
all_wildcards = include_wildcards + (exclude_wildcards or [])
299309
for wildcard in all_wildcards:
300-
accumulator = accumulator.union(glob.iglob(wildcard))
310+
accumulator = accumulator.union(glob.iglob(wildcard, recursive=True))
301311

302312
inc_files = []
303313
exc_files = []
@@ -306,7 +316,7 @@ def get_all_files(self, include_wildcards, exclude_wildcards):
306316
exc_files.append(path)
307317
else:
308318
inc_files.append(path)
309-
return (inc_files, exc_files)
319+
return (sorted(inc_files), sorted(exc_files))
310320

311321
def get_included_files(self, include_wildcards, exclude_wildcards):
312322
"""
@@ -324,10 +334,11 @@ def get_included_files(self, include_wildcards, exclude_wildcards):
324334
accumulator = set()
325335

326336
for include_wildcard in include_wildcards:
327-
accumulator = accumulator.union(glob.iglob(include_wildcard))
337+
accumulator = accumulator.union(glob.iglob(include_wildcard,
338+
recursive=True))
328339

329-
return list(path for path in accumulator
330-
if not self.is_file_excluded(path, exclude_wildcards))
340+
return sorted(path for path in accumulator
341+
if not self.is_file_excluded(path, exclude_wildcards))
331342

332343
def parse_macros(self, include, exclude=None):
333344
"""
@@ -349,6 +360,7 @@ def parse_macros(self, include, exclude=None):
349360

350361
macros = []
351362
for header_file in files:
363+
self.log.debug("Parsing macros in " + header_file)
352364
with open(header_file, "r", encoding="utf-8") as header:
353365
for line_no, line in enumerate(header):
354366
for macro in macro_regex.finditer(line):
@@ -387,6 +399,7 @@ def parse_mbed_psa_words(self, include, exclude=None):
387399

388400
mbed_psa_words = []
389401
for filename in files:
402+
self.log.debug("Parsing words in " + filename)
390403
with open(filename, "r", encoding="utf-8") as fp:
391404
for line_no, line in enumerate(fp):
392405
if exclusions.search(line):
@@ -423,6 +436,7 @@ def parse_enum_consts(self, include, exclude=None):
423436
enum_consts = []
424437
for header_file in files:
425438
state = states.OUTSIDE_KEYWORD
439+
self.log.debug("Parsing enums in " + header_file)
426440
with open(header_file, "r", encoding="utf-8") as header:
427441
for line_no, line in enumerate(header):
428442
# Match typedefs and brackets only when they are at the
@@ -539,6 +553,7 @@ def parse_identifiers_in_file(self, header_file, identifiers):
539553
Append found matches to the list ``identifiers``.
540554
"""
541555

556+
self.log.debug("Parsing identifier declarations in " + header_file)
542557
with open(header_file, "r", encoding="utf-8") as header:
543558
in_block_comment = False
544559
# The previous line variable is used for concatenating lines
@@ -614,11 +629,13 @@ def parse_identifiers(self, include, exclude=None):
614629

615630
self.log.debug("Looking for included identifiers in {} files".format \
616631
(len(included_files)))
617-
618632
included_identifiers = []
619-
excluded_identifiers = []
620633
for header_file in included_files:
621634
self.parse_identifiers_in_file(header_file, included_identifiers)
635+
636+
self.log.debug("Looking for excluded identifiers in {} files".format \
637+
(len(excluded_files)))
638+
excluded_identifiers = []
622639
for header_file in excluded_files:
623640
self.parse_identifiers_in_file(header_file, excluded_identifiers)
624641

@@ -690,6 +707,31 @@ def __init__(self, log):
690707
if not build_tree.looks_like_tf_psa_crypto_root(os.getcwd()):
691708
raise Exception("This script must be run from TF-PSA-Crypto root.")
692709

710+
H_PUBLIC = [
711+
"include/**/*.h",
712+
"drivers/*/include/**/*.h",
713+
]
714+
H_PUBLIC_EXCLUDE = [
715+
'drivers/everest/include/tf-psa-crypto/private/everest/[HhKk]*.h',
716+
'drivers/everest/include/tf-psa-crypto/private/everest/k*/*.h',
717+
'drivers/everest/include/tf-psa-crypto/private/everest/vs*/*.h',
718+
]
719+
720+
H_INTERNAL = [
721+
"core/*.h",
722+
"drivers/*/src/*.h",
723+
]
724+
725+
H_TEST_DRIVERS = [
726+
"framework/tests/include/test/drivers/*.h",
727+
]
728+
729+
C_INTERNAL = [
730+
"core/*.c",
731+
"drivers/*/library/*.c",
732+
"drivers/*/src/*.c",
733+
]
734+
693735
def comprehensive_parse(self):
694736
"""
695737
Comprehensive ("default") function to call each parsing function and
@@ -698,75 +740,20 @@ def comprehensive_parse(self):
698740
Returns a dict of parsed item key to the corresponding List of Matches.
699741
"""
700742
all_macros = {"public": [], "internal": [], "private":[]}
701-
all_macros["public"] = self.parse_macros([
702-
"include/psa/*.h",
703-
"include/tf-psa-crypto/*.h",
704-
"include/mbedtls/*.h",
705-
"drivers/builtin/include/mbedtls/*.h",
706-
"include/mbedtls/private/*.h",
707-
"drivers/builtin/include/mbedtls/private/*.h",
708-
"drivers/everest/include/everest/everest.h",
709-
"drivers/everest/include/everest/x25519.h",
710-
"drivers/everest/include/tf-psa-crypto/private/everest/everest.h",
711-
"drivers/everest/include/tf-psa-crypto/private/everest/x25519.h"
712-
])
713-
all_macros["internal"] = self.parse_macros([
714-
"core/*.h",
715-
"drivers/builtin/src/*.h",
716-
"framework/tests/include/test/drivers/*.h",
717-
])
718-
all_macros["private"] = self.parse_macros([
719-
"core/*.c",
720-
"drivers/builtin/src/*.c",
721-
])
722-
enum_consts = self.parse_enum_consts([
723-
"include/psa/*.h",
724-
"include/tf-psa-crypto/*.h",
725-
"include/mbedtls/*.h",
726-
"drivers/builtin/include/mbedtls/*.h",
727-
"include/mbedtls/private/*.h",
728-
"drivers/builtin/include/mbedtls/private/*.h",
729-
"core/*.h",
730-
"drivers/builtin/src/*.h",
731-
"core/*.c",
732-
"drivers/builtin/src/*.c",
733-
"drivers/everest/include/everest/everest.h",
734-
"drivers/everest/include/everest/x25519.h",
735-
"drivers/everest/include/tf-psa-crypto/private/everest/everest.h",
736-
"drivers/everest/include/tf-psa-crypto/private/everest/x25519.h"
737-
])
738-
identifiers, excluded_identifiers = self.parse_identifiers([
739-
"include/psa/*.h",
740-
"include/tf-psa-crypto/*.h",
741-
"include/mbedtls/*.h",
742-
"drivers/builtin/include/mbedtls/*.h",
743-
"include/mbedtls/private/*.h",
744-
"drivers/builtin/include/mbedtls/private/*.h",
745-
"core/*.h",
746-
"drivers/builtin/src/*.h",
747-
"drivers/everest/include/everest/everest.h",
748-
"drivers/everest/include/everest/x25519.h",
749-
"drivers/everest/include/tf-psa-crypto/private/everest/everest.h",
750-
"drivers/everest/include/tf-psa-crypto/private/everest/x25519.h"
751-
], ["drivers/p256-m/p256-m/p256-m.h"])
752-
mbed_psa_words = self.parse_mbed_psa_words([
753-
"include/psa/*.h",
754-
"include/tf-psa-crypto/*.h",
755-
"include/mbedtls/*.h",
756-
"drivers/builtin/include/mbedtls/*.h",
757-
"include/mbedtls/private/*.h",
758-
"drivers/builtin/include/mbedtls/private/*.h",
759-
"core/*.h",
760-
"drivers/builtin/src/*.h",
761-
"drivers/everest/include/everest/everest.h",
762-
"drivers/everest/include/everest/x25519.h",
763-
"drivers/everest/include/tf-psa-crypto/private/everest/everest.h",
764-
"drivers/everest/include/tf-psa-crypto/private/everest/x25519.h",
765-
"core/*.c",
766-
"drivers/builtin/src/*.c",
767-
"drivers/everest/library/everest.c",
768-
"drivers/everest/library/x25519.c"
769-
], ["core/psa_crypto_driver_wrappers.h"])
743+
all_macros["public"] = self.parse_macros(self.H_PUBLIC,
744+
self.H_PUBLIC_EXCLUDE)
745+
all_macros["internal"] = self.parse_macros(self.H_INTERNAL +
746+
self.H_TEST_DRIVERS)
747+
all_macros["private"] = self.parse_macros(self.C_INTERNAL)
748+
enum_consts = self.parse_enum_consts(
749+
self.H_PUBLIC + self.H_INTERNAL + self.C_INTERNAL,
750+
self.H_PUBLIC_EXCLUDE)
751+
identifiers, excluded_identifiers = self.parse_identifiers(
752+
self.H_PUBLIC + self.H_INTERNAL,
753+
self.H_PUBLIC_EXCLUDE + ["drivers/p256-m/p256-m/p256-m.h"])
754+
mbed_psa_words = self.parse_mbed_psa_words(
755+
self.H_PUBLIC + self.H_INTERNAL + self.C_INTERNAL,
756+
self.H_PUBLIC_EXCLUDE + ["core/psa_crypto_driver_wrappers.h"])
770757
symbols = self.parse_symbols()
771758

772759
return self._parse(all_macros, enum_consts, identifiers,

0 commit comments

Comments
 (0)