Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move some scripts to framework submodule #5

Closed
wants to merge 580 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
580 commits
Select commit Hold shift + click to select a range
1a1deb8
Support restyling only the specified files
gilles-peskine-arm Dec 22, 2022
6071e90
Merge pull request #6747 from gilles-peskine-arm/bignum-mod-random
mpg Dec 23, 2022
bbb0a7f
Merge pull request #6776 from gabor-mezei-arm/6222_bignum_mod_mul
mpg Dec 23, 2022
c46bb0a
Documentation improvements
gilles-peskine-arm Dec 23, 2022
5059797
Check Uncrustify returncode in code_style.py
davidhorstmann-arm Jan 4, 2023
3b1c55d
Fix incorrect typing of function in code_style.py
davidhorstmann-arm Jan 5, 2023
50dfaca
Fix pylint warnings about comparison to True
davidhorstmann-arm Jan 5, 2023
293404f
Merge pull request #6876 from davidhorstmann-arm/disable-code-style-f…
gilles-peskine-arm Jan 5, 2023
8dc85d9
Fix example command
gilles-peskine-arm Jan 12, 2023
990bb78
Add test generation support for the ecp module
gabor-mezei-arm Jan 16, 2023
12d70a9
Add generated test for ecp quasi-reduction
gabor-mezei-arm Jan 16, 2023
9b226cb
Fix pylint issues
gabor-mezei-arm Jan 17, 2023
df4464a
Fix lint issues
gabor-mezei-arm Jan 18, 2023
f048545
Refactoring: new method Algorithm.is_valid_for_operation
gilles-peskine-arm Dec 15, 2022
3325957
A key agreement cannot be chained with PSA_ALG_TLS12_ECJPAKE_TO_PMS
gilles-peskine-arm Dec 15, 2022
617b051
Merge pull request #6834 from gilles-peskine-arm/code-style-files
gilles-peskine-arm Jan 19, 2023
bf903a0
Move the quasi reduction fixing function to bignum_mod_raw
gabor-mezei-arm Jan 23, 2023
c4fe40d
Remove provisional notice on code style script
davidhorstmann-arm Jan 16, 2023
edb88c4
Document that the script must be run from the root
davidhorstmann-arm Jan 16, 2023
20694ab
Change print to print_err for an error message
davidhorstmann-arm Jan 16, 2023
b9c3833
Remove overly verbose output on success
davidhorstmann-arm Jan 16, 2023
21157c0
Fix pylint issues
gabor-mezei-arm Jan 24, 2023
7dce673
Add basic output on success
davidhorstmann-arm Jan 24, 2023
42c4850
Use reproductable random numbers
gabor-mezei-arm Jan 24, 2023
2abb538
Output diff without capturing it
davidhorstmann-arm Jan 24, 2023
3a0d806
Don't wrap stdout and stderr in UTF-8 wrapper
davidhorstmann-arm Jan 24, 2023
2813823
Give proper Dict type hints in crypto_knowledge.py
davidhorstmann-arm Jan 24, 2023
f6866ce
Remove unnecessary '\' linebreak characters
davidhorstmann-arm Jan 25, 2023
613468f
Add dependency for generated test cases
gabor-mezei-arm Jan 26, 2023
fa86a19
Merge pull request #6802 from gilles-peskine-arm/test_suite_psa_crypt…
mpg Jan 27, 2023
1d1957a
Revert "Add dependency for generated test cases"
gabor-mezei-arm Jan 27, 2023
da4b0c4
Shorten the prefix of the test case belongs to the fix quasi-reductio…
gabor-mezei-arm Jan 27, 2023
65386fd
c_build_helper.py: Move compile to helper
davidhorstmann-arm Jan 18, 2023
c3642e6
Make c_build_helper module respect HOSTCC
davidhorstmann-arm Jan 26, 2023
2995eb9
Add docstring for new compile function.
davidhorstmann-arm Jan 30, 2023
6d6209f
Switch to the new code style
gilles-peskine-arm Jan 11, 2023
914ee88
Merge pull request #6941 from gabor-mezei-arm/6375_quasi-reduction_fu…
gilles-peskine-arm Jan 31, 2023
fc04802
Add test generation support for the ecp module
gabor-mezei-arm Jan 16, 2023
e5c94b8
Add test generation for ecp_mod_p192_raw
gabor-mezei-arm Jan 25, 2023
4377cb5
Fix pylint issues
gabor-mezei-arm Jan 31, 2023
ddc3fbc
Merge pull request #6964 from davidhorstmann-arm/code-style-improvements
gilles-peskine-arm Jan 31, 2023
4b83c29
Merge pull request #6975 from davidhorstmann-arm/c-build-helper-impro…
gilles-peskine-arm Feb 7, 2023
8da7cd3
code_style.py: Apply exclusions to the file list
lpy4105 Feb 6, 2023
dc41dda
code_style.py: Add helpers to print warning and skipped files
lpy4105 Feb 6, 2023
2fc0c25
print skipped file names to stdout
lpy4105 Feb 10, 2023
39d3cb5
adjust help message
lpy4105 Feb 10, 2023
d2b2508
Merge pull request #6816 from nick-child-ibm/pkcs7_coverage
daverodgman Feb 10, 2023
45f9a2f
Add more test cases
gabor-mezei-arm Feb 13, 2023
2923ed0
Improve readability
lpy4105 Feb 14, 2023
8508172
Only check files known to git
lpy4105 Feb 15, 2023
83a19cd
Fix CI failure
lpy4105 Feb 15, 2023
b20d2c0
Merge pull request #6971 from gabor-mezei-arm/6026_Secp192r1_fast_red…
gilles-peskine-arm Feb 15, 2023
1fc3529
Add test generation for ecp_mod_p521_raw
gabor-mezei-arm Feb 6, 2023
6b348de
Fix pylint issues
gabor-mezei-arm Feb 6, 2023
0f22852
Fix 32-bit issues
gabor-mezei-arm Feb 7, 2023
d388080
Add corner case to mod_p521 tests
yanesca Feb 7, 2023
44fbcaf
Restrict input parameter size for ecp_mod_p521_raw
gabor-mezei-arm Feb 15, 2023
8959be7
Revert the addition of hex digit calculator function
gabor-mezei-arm Feb 15, 2023
f43a2c9
Fix tests for 32bit
gabor-mezei-arm Feb 16, 2023
77c489f
Merge pull request #7045 from lpy4105/issue/6947/apply-exclusions-in-…
gilles-peskine-arm Feb 21, 2023
217efa0
Use a common function to calculate the number of hex digits
gabor-mezei-arm Feb 14, 2023
7011783
Add test generation for ecp_mod_p224_raw
gabor-mezei-arm Feb 14, 2023
35626cc
Add more test cases for P224 testing
gabor-mezei-arm Feb 27, 2023
c494135
Use lower case hex number
gabor-mezei-arm Mar 1, 2023
f1cbbec
Remove unnecessary function override
gabor-mezei-arm Mar 6, 2023
1c1eb3c
Code style: have two empty lines before and after class definitions
gabor-mezei-arm Mar 6, 2023
e0a84d7
Correct the maximum canonical value in tests
gabor-mezei-arm Mar 6, 2023
c9709b3
The is_valid() function is needed to not filter out test cases
gabor-mezei-arm Mar 6, 2023
340f92f
Add test generation for ecp_mod_p256_raw
gabor-mezei-arm Mar 8, 2023
fa85e66
Add and fix comments
gabor-mezei-arm Mar 9, 2023
a970c38
Fix maximum cannonical value
gabor-mezei-arm Mar 9, 2023
6dc6947
ecp test generator: Added EcpPp384R1Raw().
minosgalanakis Mar 6, 2023
636abec
ecp_curves: Minor rework for p384
minosgalanakis Mar 9, 2023
75bdc54
EcpP384R1Raw: Added test case for 2nd round of carry reduction.
minosgalanakis Mar 20, 2023
ce6c440
Add test cases for P192 fast reduction testing
gabor-mezei-arm Mar 28, 2023
59e748a
Add test cases for P224 fast reduction testing
gabor-mezei-arm Mar 28, 2023
bf59479
Add test cases for P521 fast reduction testing
gabor-mezei-arm Mar 28, 2023
83abbc1
Typo: reformat numbers
gabor-mezei-arm Mar 28, 2023
ca9b17c
Add test cases for P384 fast reduction testing
gabor-mezei-arm Mar 28, 2023
5f5421c
Add test cases for P256 fast reduction testing
gabor-mezei-arm Mar 28, 2023
3211697
Typo: reorder testing classes
gabor-mezei-arm Mar 28, 2023
9be2525
Fix comments
gabor-mezei-arm Mar 28, 2023
dc86aa7
Fix 0 limb size for value 0
gabor-mezei-arm Mar 31, 2023
3f37a25
Add generated test for core_mul
gabor-mezei-arm Mar 31, 2023
8645c27
Multplication is simmetric so only generate unique combinations
gabor-mezei-arm Apr 3, 2023
f3c99a9
bignum: Removed merge scaffolding.
minosgalanakis Mar 21, 2023
32f3bcc
cert_audit: Initial script for auditing expiry date
lpy4105 Apr 4, 2023
109399c
cert_audit: Support audit on test suite data files
lpy4105 Apr 6, 2023
b427f27
Merge pull request #7324 from minosgalanakis/bignum/remove-scaffolding
yanesca Apr 6, 2023
ef3cd67
Merge pull request #7351 from gabor-mezei-arm/7109_ecp_fast_reduction…
yanesca Apr 6, 2023
e5624fc
test_suite_ecp: Introduced `ecp_mod_p_generic_raw`
minosgalanakis Mar 21, 2023
47f7017
ecp.py: Set test-dependencies as attributes.
minosgalanakis Apr 6, 2023
8e8cc2b
cert_audit: Parse more information from test suite data file
lpy4105 Apr 7, 2023
3b7a941
cert_audit: Introduce not-[before|after] option
lpy4105 Apr 11, 2023
2a4abc4
cert_audit: Fill validity dates in AuditData constructor
lpy4105 Apr 11, 2023
a678c0a
cert_audit: Disable pylint error for importing cryptography
lpy4105 Apr 11, 2023
adda9da
cert_audit: Make FILE as positional argument
lpy4105 Apr 13, 2023
ac593c7
cert_audit: Output line/argument number for *.data files
lpy4105 Apr 13, 2023
2184cf2
Add generated tests for ecp_mod_p192k1
gabor-mezei-arm Apr 11, 2023
1331362
Add dependency for P192K1 tests
gabor-mezei-arm Apr 13, 2023
7b02aa3
Fix test case dependency
gabor-mezei-arm Apr 17, 2023
17d14fd
cert_audit: Improve documentation
lpy4105 Apr 18, 2023
6f97d92
cert_audit: Code refinement
lpy4105 Apr 18, 2023
7ff6f7c
ecp_curves: Added unit-tests for `secp224k1`
minosgalanakis Apr 11, 2023
9dfb26f
New implementation for generate_test_code.FileWrapper
lpy4105 Apr 19, 2023
228d863
cert_audit: Reuse generate_test_code.FileWrapper
lpy4105 Apr 19, 2023
8f21dd9
cert_audit: Enable logging module
lpy4105 Apr 21, 2023
fb508f0
cert_audit: Add data-files and suite-data-files options
lpy4105 Apr 21, 2023
f948226
cert_audit: Improve the method to find tests folder
lpy4105 Apr 21, 2023
372e7a0
Merge pull request #7425 from minosgalanakis/ecp/7257_ecp_mod_p224k1_…
paul-elliott-arm Apr 21, 2023
64a5fb5
cert_audit: Add simple parser of suite data file
lpy4105 Apr 23, 2023
25d1dae
cert_audit: Clarify the abstraction of Auditor
lpy4105 Apr 23, 2023
831471a
cert_audit: Check the version of cryptography
lpy4105 Apr 25, 2023
17b7c70
cert_audit: Reword the options and their descriptions
lpy4105 Apr 25, 2023
f6a6fe8
ecp_curves: Added unit-tests for `secp256k1`
minosgalanakis Apr 11, 2023
afe5ca7
bignum_core.py: Add "BignumCoreShiftL()"
minosgalanakis Apr 25, 2023
f33ba7b
Add line number to a few error messages
gilles-peskine-arm Dec 3, 2022
e74801e
Factor get_function_info out of gen_from_test_data
gilles-peskine-arm Dec 4, 2022
2d07e7f
Simplify parsing of integers in .datax files
gilles-peskine-arm Dec 3, 2022
8f35c81
Support different types in the parameter store
gilles-peskine-arm Dec 4, 2022
4bd2ad9
parse_function_arguments: make local_vars a list
gilles-peskine-arm Dec 4, 2022
02fc566
parse_function_arguments: extract per-argument function
gilles-peskine-arm Dec 4, 2022
84fd799
Support (void) as an argument list of a test function
gilles-peskine-arm Dec 4, 2022
88d56de
parse_function_arguments: stricter type parsing
gilles-peskine-arm Dec 4, 2022
0091624
Support larger integer test arguments: C part
gilles-peskine-arm Dec 4, 2022
99be173
Allow more signed integer types in test function arguments
gilles-peskine-arm Dec 4, 2022
15018cf
Test the line number returned by parse_test_data
gilles-peskine-arm Feb 23, 2023
d8476e8
typo
gilles-peskine-arm Apr 26, 2023
ad5629d
Adjust code style for pointer types and casts
gilles-peskine-arm Apr 26, 2023
b70de43
Add Curve 448 tests
paul-elliott-arm Apr 23, 2023
379f671
Correct max canonical multiplication result
paul-elliott-arm May 3, 2023
6105259
Remove unrequired limb size calculation
paul-elliott-arm May 3, 2023
6fa83f5
Merge pull request #6716 from gilles-peskine-arm/test-argument-types-…
gilles-peskine-arm May 4, 2023
17bbca8
Merge pull request #7490 from paul-elliott-arm/test_ecp_mod_p448
paul-elliott-arm May 4, 2023
ebef055
Fix input parameter alignment in P256K1 test cases
gabor-mezei-arm May 5, 2023
ee7aedb
Merge pull request #7399 from lpy4105/issue/7014/certificate-audit-sc…
bensze01 May 9, 2023
26f0239
cert_audit: Support parsing file with multiple PEMs
lpy4105 Apr 28, 2023
12157ba
cert_audit: Merge audit_data for identical X.509 objects
lpy4105 Apr 28, 2023
318d696
cert_audit: Sort the outputs by not_valid_after date
lpy4105 Apr 28, 2023
fbe2939
cert_audit: Fix bug in check_cryptography_version
lpy4105 Apr 28, 2023
2f52f05
cert_audit: Calculate identifier for X.509 objects
lpy4105 May 5, 2023
f2bb1eb
cert_audit: Output format improvement
lpy4105 May 5, 2023
beac0bb
cert_audit: Use dictionary to store parsed AuditData
lpy4105 May 5, 2023
0217808
cert_audit: Remove merge_auditdata
lpy4105 May 6, 2023
876d933
cert_audit: Fix DER files missed from parsing
lpy4105 May 8, 2023
96fb3a7
Merge pull request #7482 from gabor-mezei-arm/6029_use_core_api_in_ec…
paul-elliott-arm May 10, 2023
6a1358e
bignum_common.py: Addressed minor typos
minosgalanakis May 11, 2023
872a5fa
Add test cases to test overflow in the Kobltz reduction
gabor-mezei-arm May 8, 2023
ef01247
bignum_core.py: Simplified result calculation for `BignumCoreShiftL`
minosgalanakis May 16, 2023
cf8826c
Add `_raw` function to P192K1
gabor-mezei-arm May 2, 2023
9c82445
Add `_raw` function to P224K1
gabor-mezei-arm May 2, 2023
1e9020a
Add `_raw` function to P256K1
gabor-mezei-arm May 2, 2023
31b3062
Merge pull request #7489 from minosgalanakis/ecp/7246_xtrack_core_shi…
paul-elliott-arm May 16, 2023
92e7937
Merge pull request #7565 from gabor-mezei-arm/7263_split_out_Koblitz_…
paul-elliott-arm May 22, 2023
b93e2ee
ecp.py: Added tests for `mbedtls_ecp_mod_p255_raw`
minosgalanakis May 11, 2023
9fd6d1e
ecp.py: Fixed types for `arguments()` overrides.
minosgalanakis May 12, 2023
7bb8019
ecp_curves: Minor refactoring of `mbedtls_ecp_mod_p255_raw()`
minosgalanakis May 17, 2023
725748a
Merge pull request #7512 from lpy4105/issue/7014/cert_audit-improvement
gilles-peskine-arm May 24, 2023
7073ae2
Merge pull request #7591 from minosgalanakis/ecp/6028_xtract_fast_red…
paul-elliott-arm Jun 1, 2023
ba37450
Move corner test case into python framework
paul-elliott-arm Jun 13, 2023
b7cbaad
Merge pull request #7637 from paul-elliott-arm/fixed_ecp_mod_p448
paul-elliott-arm Jun 15, 2023
de1a028
Split out mbedtls_ecp_mod_p448_raw()
paul-elliott-arm Jun 2, 2023
e46cde9
test_suite_ecp: Added `MBEDTLS_ECP_NIST_OPTIM` define guards.
minosgalanakis Jun 9, 2023
61af299
Clean up subprocess invocation in get_src_files
gilles-peskine-arm Jun 22, 2023
35de652
Add --since option to check files modified since a given commit
gilles-peskine-arm Jun 22, 2023
31299ca
Handle deleted files correctly
gilles-peskine-arm Jun 25, 2023
c69a549
bignum_common.py: Added `bits_to_limbs` method.
minosgalanakis Jun 27, 2023
7fe083e
ecp.py: Extended EcpP224K1Raw tests for 32/64 bit architectures.
minosgalanakis Jun 27, 2023
03b2524
Merge pull request #7822 from gilles-peskine-arm/code-style-since
daverodgman Jun 30, 2023
f877ce6
code_size_compare: add logging module and tweak prompt message
Jul 19, 2023
bd4f3cc
logging_util: rename argument
Jul 26, 2023
537fd3e
Enable DH in generate_psa_tests.py
mpg Jul 11, 2023
aa454f6
Shorten DH_FAMILY just like ECC_FAMILY
mpg Jul 18, 2023
b8f8019
Fix KeyType.can_do() for DH+FFDH
mpg Jul 18, 2023
56bab4e
Fix warnings from clang-16
gowthamsk-arm Jul 26, 2023
12cd806
Make code_style.py -s more precise
daverodgman Jul 27, 2023
7853f4e
Make code_style.py -s default to -s=development
daverodgman Jul 27, 2023
34b89f9
pylint tidy-up
daverodgman Jul 27, 2023
bb2f4d6
whitespace fix
dave-rodgman Jul 27, 2023
86fd07c
Update default variable values for compilers
gowthamsk-arm Jul 31, 2023
08984c0
Add default test cases for add/subtract in bignum
Aug 1, 2023
f00f5e4
Use ADD_SUB_DEFAULT as test input for bignum tests
Aug 1, 2023
f43c186
Rename ADD_SUB_DEFAULT to ADD_SUB_DATA
Aug 1, 2023
abd6cc9
Merge pull request #7968 from gowthamsk-arm/use_earliest_latest_compi…
bensze01 Aug 2, 2023
24d635d
Remove trailing whitespace
Aug 3, 2023
ecd6281
Merge pull request #8018 from AgathiyanB/add-overflow-test-inputs-bignum
tom-cosgrove-arm Aug 4, 2023
f335772
logging_util: support to tweak loglevel directed to stderr/stdout
Aug 14, 2023
573d74f
Merge pull request #7937 from yanrayw/code_size_compare_improvement
bensze01 Aug 17, 2023
7a19bbc
Move PSA information and dependency automation into their own module
gilles-peskine-arm Jun 19, 2023
496313d
New test suite for the low-level hash interface
gilles-peskine-arm Jun 20, 2023
6ef458a
Fix type annotation
gilles-peskine-arm Aug 9, 2023
567a828
Modify build_tree.py for the PSA Crypto repo
davidhorstmann-arm Jul 18, 2023
7f35b6b
Support psa-crypto repo in psa_storage.py
davidhorstmann-arm Jul 18, 2023
81e8e30
Improve directory coverage in PSA repo detection
davidhorstmann-arm Aug 29, 2023
2abd26d
Merge pull request #1050 from Mbed-TLS/update-restricted-2023-08-30
gilles-peskine-arm Aug 30, 2023
7021408
Merge remote-tracking branch 'upstream-public/development' into devel…
gilles-peskine-arm Sep 25, 2023
7759610
Merge pull request #1090 from Mbed-TLS/mbedtls-3.5.0rc0-pr
minosgalanakis Oct 4, 2023
4ab66b8
Correct styling of Mbed TLS in documentation
tom-daubney-arm Oct 6, 2023
7e479ed
Adapt to new PSA Crypto repo name
ronald-cron-arm Oct 9, 2023
5c899a8
Merge pull request #8327 from ronald-cron-arm/adapt-psa-crypto-repo-name
ronald-cron-arm Oct 11, 2023
2515cfa
add script for server9_bad_saltlen
yuhaoth May 23, 2023
432e00e
fix wrong typo and indent issue
yuhaoth Oct 18, 2023
20c91d5
improve document
yuhaoth Oct 24, 2023
07bc4a8
move script to `tests/scripts`
yuhaoth Oct 24, 2023
09146d7
update headers
daverodgman Nov 2, 2023
b232974
psa_information.py: generate dep for AES/ARIA/CAMELLIA ECB test case
Nov 1, 2023
3652581
Header updates
daverodgman Nov 3, 2023
b56cc53
Revert back to v3.5.0
daverodgman Nov 8, 2023
6225c84
Merge remote-tracking branch 'origin/development' into mbedtls-3.5.1-pr
daverodgman Nov 8, 2023
e803233
psa_information: compile a regex instead of using string directly
Nov 9, 2023
5fd78db
psa_information: improve code readability
Nov 13, 2023
0231c7d
Introduce function to return library/core directory
tom-daubney-arm Nov 16, 2023
a99caa8
Merge pull request #7649 from yuhaoth/pr/add-command-for-server9-bad-…
gilles-peskine-arm Nov 20, 2023
89032fb
Merge pull request #1122 from gilles-peskine-arm/development-restrict…
gilles-peskine-arm Nov 21, 2023
372e532
Improve implementation of crypto_core_directory
tom-daubney-arm Nov 22, 2023
d990342
Rename guess_mbedtls_root to guess_project_root
tom-daubney-arm Nov 22, 2023
fef67e9
Merge remote-tracking branch 'origin/development' into support_cipher…
Nov 23, 2023
acf4569
Introduce project_crypto_name in build_tree.py
tom-daubney-arm Nov 23, 2023
415486a
Use os.path.join in crypto_core_directory
tom-daubney-arm Nov 24, 2023
ebae927
Add documentation for new public functions
tom-daubney-arm Nov 24, 2023
ef87f7f
Merge remote-tracking branch 'development' into development-restricted
gilles-peskine-arm Nov 29, 2023
f880d03
Rename project_crypto_name
tom-daubney-arm Nov 30, 2023
176d3a6
Improve documentation of crypto_core_directory
tom-daubney-arm Nov 30, 2023
d2eedbd
Introduce guess_mbedtls_root
tom-daubney-arm Nov 30, 2023
19da414
Introduce guess_tf_psa_crypto_root
tom-daubney-arm Nov 30, 2023
a62109a
Remove trailing whitespace
tom-daubney-arm Dec 1, 2023
f8d0313
Modify crypto_core_directory to also return a relative path
tom-daubney-arm Dec 1, 2023
ebd3304
Use guess_mbedtls_root in Mbed-TLS-only script
tom-daubney-arm Dec 1, 2023
b9c445a
Merge pull request #1121 from gilles-peskine-arm/psa-buffers-test-poison
davidhorstmann-arm Dec 11, 2023
f487eea
Merge pull request #8523 from tom-daubney-arm/modify_check_generated_…
gilles-peskine-arm Dec 11, 2023
4bcd102
Fix mixup between secp224r1 and secp224k1 in test scripts
gilles-peskine-arm Jan 3, 2024
cee6a06
Add test data for secp192r1
gilles-peskine-arm Jan 3, 2024
903f3aa
Python module to parse function declarations from a header file
gilles-peskine-arm Nov 22, 2023
3621060
C function wrapper generator
gilles-peskine-arm Nov 22, 2023
3e62373
Guard the macro definition
gilles-peskine-arm Nov 23, 2023
c4bf74c
Add review exception warning
gilles-peskine-arm Jan 4, 2024
d4d4fb6
Fix parsing of C line comments
gilles-peskine-arm Jan 8, 2024
00a325d
tests: add guards for DH groups
valeriosetti Jan 17, 2024
214f077
Merge remote-tracking branch 'restricted/development-restricted' into…
daverodgman Jan 26, 2024
eca2a42
Merge pull request #1165 from daverodgman/update-development-r
daverodgman Feb 2, 2024
5a46f42
Merge branch 'development' into buffer-sharing-merge
davidhorstmann-arm Mar 12, 2024
aeb4fb5
Check file content to see if it looks auto-generated
daverodgman Mar 18, 2024
d2f82ca
line length fix
daverodgman Mar 18, 2024
d9f386c
Minor relaxation to auto-gen regex
daverodgman Mar 18, 2024
16deea8
Merge branch 'development' into 'development-restricted'
minosgalanakis Mar 19, 2024
f9fc138
Merge pull request #1208 from Mbed-TLS/origin/dev/minosgalanakis/deve…
minosgalanakis Mar 20, 2024
ef8b4be
Merge pull request #1213 from Mbed-TLS/mbedtls-3.6.0rc0-pr
minosgalanakis Mar 22, 2024
56e0c15
Merge branch 'scripts-history' into dev/davidhorstmann-arm/move-scripts
davidhorstmann-arm Apr 5, 2024
4765480
Replace old references to 'mbedtls_dev'
davidhorstmann-arm Mar 27, 2024
f1ef72a
Remove path import from audit-validity-dates.py
davidhorstmann-arm Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
468 changes: 468 additions & 0 deletions scripts/audit-validity-dates.py

Large diffs are not rendered by default.

230 changes: 230 additions & 0 deletions scripts/code_style.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
#!/usr/bin/env python3
"""Check or fix the code style by running Uncrustify.

This script must be run from the root of a Git work tree containing Mbed TLS.
"""
# Copyright The Mbed TLS Contributors
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
import argparse
import os
import re
import subprocess
import sys
from typing import FrozenSet, List, Optional

UNCRUSTIFY_SUPPORTED_VERSION = "0.75.1"
CONFIG_FILE = ".uncrustify.cfg"
UNCRUSTIFY_EXE = "uncrustify"
UNCRUSTIFY_ARGS = ["-c", CONFIG_FILE]
CHECK_GENERATED_FILES = "tests/scripts/check-generated-files.sh"

def print_err(*args):
print("Error: ", *args, file=sys.stderr)

# Print the file names that will be skipped and the help message
def print_skip(files_to_skip):
print()
print(*files_to_skip, sep=", SKIP\n", end=", SKIP\n")
print("Warning: The listed files will be skipped because\n"
"they are not known to git.")
print()

# Match FILENAME(s) in "check SCRIPT (FILENAME...)"
CHECK_CALL_RE = re.compile(r"\n\s*check\s+[^\s#$&*?;|]+([^\n#$&*?;|]+)",
re.ASCII)
def list_generated_files() -> FrozenSet[str]:
"""Return the names of generated files.

We don't reformat generated files, since the result might be different
from the output of the generator. Ideally the result of the generator
would conform to the code style, but this would be difficult, especially
with respect to the placement of line breaks in long logical lines.
"""
# Parse check-generated-files.sh to get an up-to-date list of
# generated files. Read the file rather than calling it so that
# this script only depends on Git, Python and uncrustify, and not other
# tools such as sh or grep which might not be available on Windows.
# This introduces a limitation: check-generated-files.sh must have
# the expected format and must list the files explicitly, not through
# wildcards or command substitution.
content = open(CHECK_GENERATED_FILES, encoding="utf-8").read()
checks = re.findall(CHECK_CALL_RE, content)
return frozenset(word for s in checks for word in s.split())

# Check for comment string indicating an auto-generated file
AUTOGEN_RE = re.compile(r"Warning[ :-]+This file is (now )?auto[ -]?generated",
re.ASCII | re.IGNORECASE)
def is_file_autogenerated(filename):
content = open(filename, encoding="utf-8").read()
return AUTOGEN_RE.search(content) is not None

def get_src_files(since: Optional[str]) -> List[str]:
"""
Use git to get a list of the source files.

The optional argument since is a commit, indicating to only list files
that have changed since that commit. Without this argument, list all
files known to git.

Only C files are included, and certain files (generated, or 3rdparty)
are excluded.
"""
file_patterns = ["*.[hc]",
"tests/suites/*.function",
"scripts/data_files/*.fmt"]
output = subprocess.check_output(["git", "ls-files"] + file_patterns,
universal_newlines=True)
src_files = output.split()
if since:
# get all files changed in commits since the starting point
cmd = ["git", "log", since + "..HEAD", "--name-only", "--pretty=", "--"] + src_files
output = subprocess.check_output(cmd, universal_newlines=True)
committed_changed_files = output.split()
# and also get all files with uncommitted changes
cmd = ["git", "diff", "--name-only", "--"] + src_files
output = subprocess.check_output(cmd, universal_newlines=True)
uncommitted_changed_files = output.split()
src_files = list(set(committed_changed_files + uncommitted_changed_files))

generated_files = list_generated_files()
# Don't correct style for third-party files (and, for simplicity,
# companion files in the same subtree), or for automatically
# generated files (we're correcting the templates instead).
src_files = [filename for filename in src_files
if not (filename.startswith("3rdparty/") or
filename in generated_files or
is_file_autogenerated(filename))]
return src_files

def get_uncrustify_version() -> str:
"""
Get the version string from Uncrustify
"""
result = subprocess.run([UNCRUSTIFY_EXE, "--version"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
check=False)
if result.returncode != 0:
print_err("Could not get Uncrustify version:", str(result.stderr, "utf-8"))
return ""
else:
return str(result.stdout, "utf-8")

def check_style_is_correct(src_file_list: List[str]) -> bool:
"""
Check the code style and output a diff for each file whose style is
incorrect.
"""
style_correct = True
for src_file in src_file_list:
uncrustify_cmd = [UNCRUSTIFY_EXE] + UNCRUSTIFY_ARGS + [src_file]
result = subprocess.run(uncrustify_cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, check=False)
if result.returncode != 0:
print_err("Uncrustify returned " + str(result.returncode) +
" correcting file " + src_file)
return False

# Uncrustify makes changes to the code and places the result in a new
# file with the extension ".uncrustify". To get the changes (if any)
# simply diff the 2 files.
diff_cmd = ["diff", "-u", src_file, src_file + ".uncrustify"]
cp = subprocess.run(diff_cmd, check=False)

if cp.returncode == 1:
print(src_file + " changed - code style is incorrect.")
style_correct = False
elif cp.returncode != 0:
raise subprocess.CalledProcessError(cp.returncode, cp.args,
cp.stdout, cp.stderr)

# Tidy up artifact
os.remove(src_file + ".uncrustify")

return style_correct

def fix_style_single_pass(src_file_list: List[str]) -> bool:
"""
Run Uncrustify once over the source files.
"""
code_change_args = UNCRUSTIFY_ARGS + ["--no-backup"]
for src_file in src_file_list:
uncrustify_cmd = [UNCRUSTIFY_EXE] + code_change_args + [src_file]
result = subprocess.run(uncrustify_cmd, check=False)
if result.returncode != 0:
print_err("Uncrustify with file returned: " +
str(result.returncode) + " correcting file " +
src_file)
return False
return True

def fix_style(src_file_list: List[str]) -> int:
"""
Fix the code style. This takes 2 passes of Uncrustify.
"""
if not fix_style_single_pass(src_file_list):
return 1
if not fix_style_single_pass(src_file_list):
return 1

# Guard against future changes that cause the codebase to require
# more passes.
if not check_style_is_correct(src_file_list):
print_err("Code style still incorrect after second run of Uncrustify.")
return 1
else:
return 0

def main() -> int:
"""
Main with command line arguments.
"""
uncrustify_version = get_uncrustify_version().strip()
if UNCRUSTIFY_SUPPORTED_VERSION not in uncrustify_version:
print("Warning: Using unsupported Uncrustify version '" +
uncrustify_version + "'")
print("Note: The only supported version is " +
UNCRUSTIFY_SUPPORTED_VERSION)

parser = argparse.ArgumentParser()
parser.add_argument('-f', '--fix', action='store_true',
help=('modify source files to fix the code style '
'(default: print diff, do not modify files)'))
parser.add_argument('-s', '--since', metavar='COMMIT', const='development', nargs='?',
help=('only check files modified since the specified commit'
' (e.g. --since=HEAD~3 or --since=development). If no'
' commit is specified, default to development.'))
# --subset is almost useless: it only matters if there are no files
# ('code_style.py' without arguments checks all files known to Git,
# 'code_style.py --subset' does nothing). In particular,
# 'code_style.py --fix --subset ...' is intended as a stable ("porcelain")
# way to restyle a possibly empty set of files.
parser.add_argument('--subset', action='store_true',
help='only check the specified files (default with non-option arguments)')
parser.add_argument('operands', nargs='*', metavar='FILE',
help='files to check (files MUST be known to git, if none: check all)')

args = parser.parse_args()

covered = frozenset(get_src_files(args.since))
# We only check files that are known to git
if args.subset or args.operands:
src_files = [f for f in args.operands if f in covered]
skip_src_files = [f for f in args.operands if f not in covered]
if skip_src_files:
print_skip(skip_src_files)
else:
src_files = list(covered)

if args.fix:
# Fix mode
return fix_style(src_files)
else:
# Check mode
if check_style_is_correct(src_files):
print("Checked {} files, style ok.".format(len(src_files)))
return 0
else:
return 1

if __name__ == '__main__':
sys.exit(main())
3 changes: 3 additions & 0 deletions scripts/framework_dev/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file needs to exist to make framework_dev a package.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think framework_dev is right as a package name. Unless that's intended to be a sub-package of some mbedtls package? The idea with calling the directory mbedtls_dev is that you can use it in a program that isn't specific to Mbed TLS, for example a program that puts multiple crypto libraries together and uses some code from mbedtls_dev to obtain information about things like supported crypto mechanisms. So the name should keep mbedtls in it.

The current name is mbedtls_dev because it's for development of or related to Mbed TLS, as opposed to mbedtls which should be reserved for a Python package that contains wrappers around Mbed TLS's C APIs. We could keep that name here. Or maybe change it to mbedtls_framework?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy with mbedtls_dev but I was assuming we'd want to generalise it given that it'll be used in TF-PSA-Crypto. I'll change this back to mbedtls_dev.

# Among other things, this allows modules in this directory to make
# relative imports.
Loading