Commit graph

1480 commits

Author SHA1 Message Date
Gilles Peskine
efaee9a299 Give a production-sounding name to the p256m option
Now that p256-m is officially a production feature and not just an example,
give it a more suitable name.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-20 20:49:47 +02:00
Manuel Pégourié-Gonnard
5edb942708
Merge pull request #8041 from mpg/tfm-p256m
Test TF-M config with p256-m driver
2023-09-20 16:09:56 +00:00
Gilles Peskine
bd50d5baec
Merge pull request #8177 from gilles-peskine-arm/generated-files-off-in-release
Generated files off in release
2023-09-18 14:11:58 +00:00
Gilles Peskine
67c86e626b
Merge pull request #7961 from gilles-peskine-arm/psa_crypto_config-in-full
Enable MBEDTLS_PSA_CRYPTO_CONFIG in the full config
2023-09-18 08:13:12 +00:00
Dave Rodgman
da0bb9fae8
Merge pull request #8034 from gilles-peskine-arm/bump_version-doc_mainpage
Update capitalization of "Mbed" and fix bump_version.sh
2023-09-13 08:41:20 +00:00
Gilles Peskine
e820c0abc8 Update spelling "mbed TLS" to "Mbed TLS"
The official spelling of the trade mark changed from all-lowercase "mbed"
to normal proper noun capitalization "Mbed" a few years ago. We've been
using the new spelling in new text but still have the old spelling in a
lot of text. This commit updates most occurrences of "mbed TLS":

```
sed -i -e 's/mbed TLS/Mbed TLS/g' $(git ls-files ':!ChangeLog' ':!tests/data_files/**' ':!tests/suites/*.data' ':!programs/x509/*' ':!configs/tfm*')
```

Justification for the omissions:

* `ChangeLog`: historical text.
* `test/data_files/**`, `tests/suites/*.data`, `programs/x509/*`: many
  occurrences are significant names in certificates and such. Changing
  the spelling would invalidate many signatures and tests.
* `configs/tfm*`: this is an imported file. We'll follow the upstream
  updates.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-12 19:18:17 +02:00
Gilles Peskine
4843278237 Allow "Mbed TLS" as the project name in Doxygen
Previously the code only recognized the old spelling "mbed TLS", so it
missed doxygen/input/doc_mainpage.h.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-12 19:16:17 +02:00
Gilles Peskine
1d9e8f1a07
Merge pull request #7797 from gilles-peskine-arm/python-cryptography-on-windows
Revert "Install cryptography only on linux platform"
2023-09-12 13:58:10 +00:00
Manuel Pégourié-Gonnard
138bdb6b17 Add comment to p256-m driver JSON file
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-09-12 09:50:18 +02:00
Manuel Pégourié-Gonnard
92a386f24c Add JSON file for p256-m driver
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-09-12 09:50:16 +02:00
Ronald Cron
9b9ac4c6ef
Merge pull request #8175 from ronald-cron-arm/fix-query-config-generation-with-cmake
Fix query_config.c generation with CMake build system
2023-09-12 06:03:01 +00:00
Dave Rodgman
7fda906a68
Merge pull request #8161 from gilles-peskine-arm/config-boolean-options-wrong-section-202309
Fix module configuration options in mbedtls_config.h
2023-09-11 15:08:56 +00:00
Gilles Peskine
eeed74e697 Fix prepare_release.sh -u with CMakeLists.txt
We want to keep GEN_FILES defaulting off on Windows.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-09 21:00:30 +02:00
Gilles Peskine
473f6363f1 In releases, turn off GEN_FILES in Makefile and CMakeLists.txt
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-08 16:56:58 +02:00
Gilles Peskine
dea4c7e09f Prepare to generalize the script to do more than .gitignore
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-08 16:34:01 +02:00
Ronald Cron
d7a983a0d8 Fix generate_query_config.pl usage
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2023-09-08 10:53:35 +02:00
Ronald Cron
eab2055bde Fix query_config.c generation with CMake build system
In case of an out-of-tree build with the CMake build
system the path to crypto_config.h has to be defined
as the path to mbedtls_config.h. Add this possibility
tp generate_query_config.pl.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2023-09-08 10:23:25 +02:00
Gilles Peskine
a8861e086e Fix boolean options in the wrong section
Boolean options that modify the behavior of a module are supposed to be in
the "feature support" section, not in the "configuration options" support:
that section is documented to contain commented-out definitions with a
value, for which the comment contains the default version. In particular,
merely uncommenting a definition in the "configuration options" section is
not supposed to change anything.

Move the offending boolean options to the proper section.

This causes those options to be enabled by `config.py full` unless
explicitly excluded. For all the offending options, this is undesirable, so
make sure those options are indeed excluded.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-09-05 20:20:51 +02:00
Dave Rodgman
4f69668558
Merge pull request #8082 from daverodgman/misc-code-size
Misc code size improvements
2023-09-02 11:44:31 +00:00
Dave Rodgman
a9a53a05f0 Merge remote-tracking branch 'origin/development' into misc-code-size 2023-08-31 11:53:46 +01:00
Gilles Peskine
7990a3296d Explain the story about cryptography version requirements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-31 09:30:56 +02:00
Gilles Peskine
03e9dea30b Merge remote-tracking branch 'development' into psa_crypto_config-in-full
Conflicts:
* `include/psa/crypto_sizes.h`: the addition of the `u` suffix in this branch
  conflicts with the rework of the calculation of `PSA_HASH_MAX_SIZE` and
  `PSA_HMAC_MAX_HASH_BLOCK_SIZE` in `development`. Use the new definitions
  from `development`, and add the `u` suffix to the relevant constants.
2023-08-30 18:32:57 +02:00
Dave Rodgman
787011542b Fully replace mbedtls_psa_safer_memcmp
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-29 14:20:18 +01:00
David Horstmann
2fde99962d Improve directory coverage in PSA repo detection
Check for the 'drivers' and 'programs' directories additionally to the
ones that are already there.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-29 09:50:16 +01:00
Gilles Peskine
7be571ac85 Remove GNUTLS_LEGACY and OPENSSL_LEGACY
They aren't used anywhere.

Keep the command line options of all.sh to avoid breaking any wrapper
scripts that people might have.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-27 21:51:54 +02:00
David Horstmann
42f42f4394 Support psa-crypto repo in psa_storage.py
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-24 15:18:18 +01:00
David Horstmann
795d8b523d Modify build_tree.py for the PSA Crypto repo
When detecting the root dir, look both for PSA Crypto and Mbed TLS
directories.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-24 15:18:18 +01:00
Gilles Peskine
dc23236f0a Revert "Install cryptography only on linux platform"
This reverts commit eb2c39ed2b.

We temporarily turned off the cryptography requirement on Windows due to a
CI instance that had an old, incompatible verison of pip. That CI instance
has been upgraded so we no longer need the workaround.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-22 17:24:45 +02:00
Gilles Peskine
ad7725d95d Fix type annotation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-22 09:59:50 +02:00
Gilles Peskine
c9187c5866 New test suite for the low-level hash interface
Some basic test coverage for now:

* Nominal operation.
* Larger output buffer.
* Clone an operation and use it after the original operation stops.

Generate test data automatically. For the time being, only do that for
hashes that Python supports natively. Supporting all algorithms is future
work.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-22 09:59:42 +02:00
Gilles Peskine
fdb722384b Move PSA information and dependency automation into their own module
This will let us use these features from other modules (yet to be created).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-21 18:32:11 +02:00
Bence Szépkúti
505dffd5e3
Merge pull request #7937 from yanrayw/code_size_compare_improvement
code_size_compare.py: preparation work to show code size changes in PR comment
2023-08-17 20:59:11 +00:00
Gilles Peskine
73936868b8 Merge remote-tracking branch 'development' into psa_crypto_config-in-full
Conflicts:
* tests/scripts/all.sh: component_test_crypto_full_no_cipher was removed
  in the development branch.
2023-08-17 19:46:34 +02:00
Yanray Wang
bc775c48c9 code_size_compare: handle deleted files and new files properly
'Removed' and 'NotCreated' should be displayed in new and old column
respectively. The value of delta is reflected on change column. This
commit handles the corner cases properly.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-08-16 16:08:22 +08:00
Yanray Wang
8a25e6fdb2 code_size_compare: add old text and data section in CSV output
To keep a concise markdown table, we don't list text and data
section from old Git revision. However, it should be ideal to keep
those two sections in CSV output. Therefore, we list comparison
result for CSV output in following format:

 filename new(text) new(data) old(text) old(data) change(text) change(data)

Additionally, if a file only exits in new Git revision not in old
Git revision, it's marked as `NotCreated` as we haven't created this
file yet from perspective of old Git revision.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-08-14 15:22:36 +08:00
Yanray Wang
0de1183e4c code_size_compare: add + in front of positive values
In comparison result, to indicate it's a delta value, we add `+` in
front of positive values. For unchanged attributes, it's still
shown as `0'.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-08-14 11:58:48 +08:00
Yanray Wang
9a6ee71f6f code_size_compare: right-align numbers in the comparison result
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-08-14 11:30:27 +08:00
Yanray Wang
1998aac349 logging_util: support to tweak loglevel directed to stderr/stdout
Previously we set loglevel >= WARNING printed to stderr and
loglevel < WARNING printed to stdout. To be more flexible, we
replace this `WARNING` value with an argument: split_level and leave
`WARNING` as default split_level if not set.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-08-14 11:22:34 +08:00
Paul Elliott
2f12a29cdd
Merge pull request #7896 from AgathiyanB/gitignore-generated-files-toggle
Add script to toggle ignoring generated files
2023-08-09 14:54:32 +00:00
Manuel Pégourié-Gonnard
8550e0f746 Remove "export_key" from transparent driver json
Transparent drivers don't have this entry points. Other entry points
that are only for opaque drivers are not listed here but only in the
opaque_driver.json file, so this was likely a mistake.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-08-08 09:39:39 +02:00
Tom Cosgrove
2588f8d36d
Merge pull request #8018 from AgathiyanB/add-overflow-test-inputs-bignum
[Bignum] Add overflow test inputs for add and add if
2023-08-04 14:00:39 +00:00
Agathiyan Bragadeesh
b8bd604379 Remove trailing whitespace
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-04 14:14:11 +01:00
Agathiyan Bragadeesh
3bcff5431a Put both gitignore modifications in one script
New file also contains a header file and uses sed

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-04 14:13:08 +01:00
Agathiyan Bragadeesh
3c963eefe2 Remove trailing whitespace
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-03 12:32:09 +01:00
Bence Szépkúti
9661f8ab0d
Merge pull request #7968 from gowthamsk-arm/use_earliest_latest_compilers
Use earliest latest compilers
2023-08-02 05:58:02 +00:00
Agathiyan Bragadeesh
ab329c0dfc Rename ADD_SUB_DEFAULT to ADD_SUB_DATA
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-01 17:18:31 +01:00
Agathiyan Bragadeesh
59003c70ae Use ADD_SUB_DEFAULT as test input for bignum tests
In BignumCoreAddAndAddIf and BignumCoreSub we use the new dedicated
test inputs.

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-01 16:32:36 +01:00
Agathiyan Bragadeesh
7847eaef20 Add default test cases for add/subtract in bignum
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-01 16:30:51 +01:00
Janos Follath
5b7c38f673 Sort full config exceptions in config.py
The EXCLUDE_FROM_FULL list in config.py should be, and used to be, but
no longer is, in alphabetical order, and with a comma on the last
element.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-08-01 08:51:12 +01:00
Janos Follath
3ed980d60f Fix full config in config.py
By default, the full configuration enables all options. But we
specifically don't want to enable MBEDTLS_ECP_WITH_MPI_UINT except where
it's done explicitly, because it disables the old ecp. So it needs to be
added to the exceptions in config.py (EXCLUDE_FROM_FULL).

Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-07-31 16:27:04 +01:00
Gowtham Suresh Kumar
6f1977bf20 Use variables for selecting compilers
The latest and earliest clang/GCC compilers are now used through
variables instead of symlinks and also the all.sh script is updated
to support options for overriding the default values.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-07-28 17:04:47 +01:00
Yanray Wang
ee07afa205 code_size_compare: add option '--show-all'
When '--show-all' is enabled, all the objects will be displayed in
comparison result no matter if there is code size change or not.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-28 16:43:56 +08:00
Yanray Wang
b167320e27 code_size_compare: use '.md' suffix if '--markdown' enabled
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-28 16:24:17 +08:00
Yanray Wang
dcf360dd72 code_size_compare: track removed object as well
It makes sense to display code size changes if a file has been
removed in our library. With this commit we track old objects as
well. If a file is not present in the new Git revision,
we display -old_size in the new_size column. The size change is
marked as `Removed` to indicate the file has been removed.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-28 16:05:37 +08:00
Dave Rodgman
fccc5f8b9d whitespace fix
Signed-off-by: Dave Rodgman <dave.rodgman@gmail.com>
2023-07-27 20:00:41 +01:00
Dave Rodgman
82d174a6a8 pylint tidy-up
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-07-27 18:51:06 +01:00
Dave Rodgman
eaf2761ae1 Make code_style.py -s default to -s=development
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-07-27 17:43:55 +01:00
Dave Rodgman
05b60f40ac Make code_style.py -s more precise
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-07-27 17:43:48 +01:00
Yanray Wang
4dfc132bcb code_size_compare: change format for comparison result
The result format for code size comparison is:

filename new(text) new(data) change(text) change(data)
yyy.o    xxx       xxx       xx           xx

The numbers followed are in bytes.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-27 10:47:21 +08:00
Yanray Wang
6f09267646 code_size_compare: remove column of percentage for code size change
Percentage is not a useful number when looking at code size changes.
Since it depends on the base of the code size. It might give
misleading information by simply looking at the numbers.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-27 10:19:38 +08:00
Gowtham Suresh Kumar
a12baf8c5f Update test scripts to use latest/earliest compilers
The Ubuntu 16.04 and 22.04 docker images have been updated with
earliest and latest versions of gcc and clang respectively.
This patch adds the necessary component and support functions
required for the CI to run these compilers.

For FreeBSD we invoke the function by name so a condition is added
to disable the existing test_clang_opt function for linux.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-07-26 16:51:45 +01:00
Yanray Wang
ca9a3cbc1d code_size_compare: detect architecture of x86_32 properly
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-26 17:21:10 +08:00
Yanray Wang
6ae94a0a72 code_size_compare: make sure _remove_worktree executed
Add try and finally to make sure we remove worktree as expected even
if we hit errors by accident.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-26 17:13:24 +08:00
Yanray Wang
9e8b671b1c code_size_compare: check --record-dir properly
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-26 15:37:29 +08:00
Manuel Pégourié-Gonnard
182eb1514e Fix KeyType.can_do() for DH+FFDH
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-07-26 09:34:30 +02:00
Manuel Pégourié-Gonnard
636d85724a Shorten DH_FAMILY just like ECC_FAMILY
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-07-26 09:32:42 +02:00
Manuel Pégourié-Gonnard
afe4b79114 Enable DH in generate_psa_tests.py
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-07-26 09:32:42 +02:00
Yanray Wang
a279ca9ff8 code_size_compare: remove unnecessary -r in cp command
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-26 15:01:12 +08:00
Yanray Wang
6ef5049b9f code_size_compare: simplify some code for python dictionary
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-26 14:59:39 +08:00
Yanray Wang
15b1358f22 logging_util: rename argument
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-26 14:48:12 +08:00
Yanray Wang
68265f41d7 code_size_compare: use current as default new Git revision
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-26 14:45:00 +08:00
Yanray Wang
bef1acd7b8 code_size_compare: left align file names in markdown table
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-26 11:07:49 +08:00
Yanray Wang
ea842e791b code_size_compare: print prompt message under correct condition
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-26 11:03:11 +08:00
Yanray Wang
533cde22c0 code_size_compare: set log level as ERROR in option --stdout
If we use option --stdout, the logging level is set as
logging.ERROR. But --verbose is able to overwrite logging level as
logging.INFO if we want to display intermediate log in the process
of code size comparison.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-26 10:27:10 +08:00
Yanray Wang
2ba9df2c1b code_size_compare: direct error message by logger.error
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-26 10:11:34 +08:00
Yanray Wang
e4a3636fac code_size_compare: add comments to make code more readable
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-25 10:37:12 +08:00
Yanray Wang
25bd331899 code_size_compare: round percentage to an integer value
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-25 10:24:23 +08:00
Yanray Wang
f2cd717952 code_size_compare: print 'None' if comparing size for a new file
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 18:07:15 +08:00
Yanray Wang
69262fc087 code_size_compare: add extra indication if print to sys.stdout
If we output comparison result into sys.stdout, it will print an
extra line to show information we used for code size comparison in
detail. This would be helpful if we copy & paste code size changes
in Github comment.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 18:07:15 +08:00
Yanray Wang
a6cf692e2a code_size_compare: simplify how to generate file name of code size
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 18:07:15 +08:00
Yanray Wang
950590099d code_size_compare: simplify CodeSizeGeneratorWithSize
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 18:07:15 +08:00
Yanray Wang
5605c6f58f code_size_compare: make CodeSizeBuildInfo more flexible
This commit changes how to infer make command. Although we haven't
supported to pass more options in command line, this is the
preparation work to support those features.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 18:07:15 +08:00
Yanray Wang
955671b0ef code_size_compare: replace SimpleNameSpace to a clearer data struct
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 18:07:15 +08:00
Yanray Wang
5b64e4c7e0 code_size_compare: clean up comments
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 18:07:15 +08:00
Yanray Wang
386c2f9e93 code_size_compare: clean up code to make it more readable
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 18:07:15 +08:00
Yanray Wang
21127f7095 code_size_compare: add logging module and tweak prompt message
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 18:07:12 +08:00
Yanray Wang
227576aaa4 code_size_compare: add option --stdout to show result in sys.stdout
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 16:44:50 +08:00
Yanray Wang
b664cb7569 code_size_compare: add --markdown to show result in a markdown table
The option --markdown supports to only show the files that
have changed in a markdown table between two commits.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 16:44:50 +08:00
Yanray Wang
9b174e90d3 code_size_compare: generate text,data as comparison result
Previously we used dec(total) as comparison result of code size
measurement. However, it's not accurate because dec(total) is
the sum of text, data and bss. Now we show text,data instead
since those are sections we care about in code size perspective
specifically for TF-M.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 16:44:50 +08:00
Yanray Wang
802af160b4 code_size_compare: support to measure code size with multiple tools
For time being, code_size_compare.py only supports `size`. This
commit builds up foundation to extend code size measurement with
other tools.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 16:44:50 +08:00
Yanray Wang
923f943a3e code_size_compare: introduce SimpleNamespace to store info
We use SimpleNamespace class to store all the information used to
measure code size of objects in library.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 16:44:50 +08:00
Yanray Wang
5e9130a5e9 code_size_compare: simplify methods in CodeSizeComparison
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 16:44:50 +08:00
Yanray Wang
e0e276046b code_size_compare: add CodeSizeCalculator to calculate code size
CodeSizeCalculator is aimed to calculate code size based on a Git
revision and code size measurement tool. The output of code size is
in utf-8 encoding.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 16:44:50 +08:00
Yanray Wang
15c43f3407 code_size_compare: add a base class as CodeSizeGenerator
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 16:44:50 +08:00
Yanray Wang
fc6ed4ddad code_size_compare: add a parser to generate code size with size tool
This commit splits CodeSizeBase as a separate class to prepare a
parser as CodeSizeGenerator. The benefit is we can extend the tool
of code size measurement in order to generate more types of code
size record.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-24 16:44:50 +08:00
Gilles Peskine
7eea4a7a80 Enable MBEDTLS_PSA_CRYPTO_CONFIG in "config.py full"
Back when we introduced MBEDTLS_PSA_CRYPTO_CONFIG and it was still
experimental, it made sense that we tested it separately. Nowadays, the
feature is fully implemented, and the full config without
MBEDTLS_PSA_CRYPTO_CONFIG keeps cryptographic mechanisms that only have a
PSA implementation and aren't in the default build disabled (currently:
PBKDF2). So enable MBEDTLS_PSA_CRYPTO_CONFIG in the full config.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-21 17:50:49 +02:00
Gilles Peskine
5647d06be8
Merge pull request #7518 from gilles-peskine-arm/psa_inject_entropy-file-stability
Fix and test MBEDTLS_PSA_INJECT_ENTROPY
2023-07-21 17:37:15 +02:00
Agathiyan Bragadeesh
cf3554b4e8 Update file permissions
New scripts have updated executable permissions to be consistent with
project requirements.

Signed-off-by: Agathiyan Bragadeesh <agabra02@e127300.arm.com>
2023-07-06 18:10:19 +01:00
Agathiyan Bragadeesh
237f91a9ef Add script to manage gitignore anchors
Added scripts which comment and uncomment out patterns relating to
generated files.

Signed-off-by: Agathiyan Bragadeesh <agabra02@e127300.arm.com>
2023-07-06 18:00:48 +01:00
Yanray Wang
699a6c8a6d code_size_compare.py: add comment for sys_arch
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-04 17:27:45 +08:00
Yanray Wang
4c26db0845 code_size_compare.py: run make clean before build libraries
If we don't remove all executable files in current working
directory, we might measure code size between different architecture
and configuration. This generates a wrong code size comparison
report. This commit guarantees it runs `make clean` before build
libraries for code size comparison.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-04 17:27:45 +08:00
Tom Cosgrove
1940e7bae4
Merge pull request #7671 from yanrayw/7360-code-size-improve-format
code size: improve format of csv file
2023-07-04 09:15:48 +01:00
Dave Rodgman
38939f705a
Merge pull request #7822 from gilles-peskine-arm/code-style-since
code_style.py --since
2023-06-30 11:37:02 +01:00
Paul Elliott
92a55bf5ea
Merge pull request #7793 from minosgalanakis/ecp/6025_fast_reduction_dispatch
[Bignum] Fast reduction dispatch
2023-06-28 17:38:37 +01:00
Minos Galanakis
dae4c038f8 ecp.py: Extended EcpP224K1Raw tests for 32/64 bit architectures.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-27 18:54:53 +01:00
Minos Galanakis
80c4ae893c bignum_common.py: Added bits_to_limbs method.
This patch introduces a rounding-error-resiliant method to
calculate bits_to_limbs, and is updating `SECP224R1` and
`SECP224K1` to use it.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-27 16:38:22 +01:00
Gilles Peskine
717a83164e
Merge pull request #7807 from gilles-peskine-arm/mbedtls_ssl_protocol_version_str-no_array
Fix very high stack usage in SSL debug code
2023-06-26 09:36:53 +02:00
Gilles Peskine
163ec4090e Handle deleted files correctly
Don't attempt to run on a file that isn't present now.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-06-25 22:18:40 +02:00
Gilles Peskine
9d7b24fb26 Fix extra character in debug string
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-06-23 21:11:46 +02:00
Gilles Peskine
43838b8a24 Add --since option to check files modified since a given commit
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-06-22 20:31:02 +02:00
Gilles Peskine
22eb82cb8d Clean up subprocess invocation in get_src_files
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-06-22 19:45:01 +02:00
Gilles Peskine
fd235bc9df Fix very high stack usage in SSL debug code
Use a switch instead of an array. The array was very hollow for some enum
types such as mbedtls_ssl_protocol_version (which formerly used small
values, but switched to using the protocol encoding as enum values in Mbed
TLS 3.2.0). Optimizing compilers know how to compile a switch into a lookup
table when the range warrants it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-06-20 17:48:18 +02:00
Minos Galanakis
450abfd922 test_suite_ecp: Added MBEDTLS_ECP_NIST_OPTIM define guards.
This patch updates `ecp_mod_p_generic_raw` and corresponding
curve test methods, that depend on the NIST optimisation
parameter to not run when it is not included.

The following curves are affected:
* SECP192R1
* SECP224R1
* SECP256R1
* SECP384R1
* SECP521R1

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-16 13:48:47 +01:00
Paul Elliott
a2e48f751b Split out mbedtls_ecp_mod_p448_raw()
Switch testing over to using the generic raw functions.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-06-15 17:16:38 +01:00
Paul Elliott
b4df176610
Merge pull request #7637 from paul-elliott-arm/fixed_ecp_mod_p448
[Bignum] Fixed width for ecp mod p448
2023-06-15 17:12:02 +01:00
Gilles Peskine
0fe0c0cf10
Merge pull request #7775 from daverodgman/version_features_codesize
Shorten encoding of version features
2023-06-15 14:56:00 +02:00
Tom Cosgrove
6edf8b8c7b
Merge pull request #7451 from yanrayw/7376_aes_128bit_only
Introduce config option of 128-bit key only in AES calculation
2023-06-15 10:35:32 +01:00
Dave Rodgman
b28d1c3484 fix check-names failure
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-14 20:06:43 +01:00
Dave Rodgman
90dfc21f6b Shorten encoding of version features
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-14 17:06:53 +01:00
Paul Elliott
b727042501 Move corner test case into python framework
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-06-13 17:42:01 +01:00
Dave Rodgman
05d71ffe5b Merge remote-tracking branch 'origin/development' into sha3-updated 2023-06-07 18:02:04 +01:00
Yanray Wang
c7a2a6d11d code_size_compare.py: change prompt message in code size measurement
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-06-05 09:54:56 +08:00
Yanray Wang
72b105f1ae code_size_compare: clarify input and return types
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-06-05 09:54:56 +08:00
Yanray Wang
8804db9d99 code_size_compare.py: integrate code with CodeSizeBase
The code size measurement script generates code size
record / comparison csv file in a more readable format.

The script won't generate new record file if there is an existing
one. It reads the record and stores data into dictionary of code_size
for comparison.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-06-05 09:54:56 +08:00
Yanray Wang
16ebc5725b code_size_compare.py: add a CodeSizeBase class
CodeSizeBase class aims to store size information for a specific
revision. It also has support to write csv report, comparison result
in a more readable format. This commit lays out foundation to
simplify code for CodeSizeComparison.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-06-05 09:54:56 +08:00
Tom Cosgrove
32b06f50df
Merge pull request #7650 from yanrayw/7360-code-size-tfm-medium
code size measurement support for tfm-medium
2023-06-02 13:25:26 +01:00
Yanray Wang
21f1744d76 code_size_compare.py: fix make command logic in default config
If system architecture doesn't match architecture of input argument
for default configuration, it's reported as an error.

Additionally, it prints out help message to show which architecture
and configuration option should be used.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-06-01 23:26:48 +08:00
Yanray Wang
502c54f8c1 code_size_compare.py: classify arguments in parser
This commit splits parsed arguments into required group and optional
group to present help message clearer to users.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-05-31 11:46:54 +08:00
Yanray Wang
c18cd89b71 code_size_compare.py: add prompt for unsupported arch and config
Add prompt message for a series of supported combination of
architecture and configuration when someone tries unsupported
combinations.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-05-31 11:46:35 +08:00
Yanray Wang
aba7158a6f code_size_compare.py: add armv8-m option for arch
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-05-29 17:16:56 +08:00
Yanray Wang
60430bda37 code_size_compare.py: change default path of armclang
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-05-29 14:48:23 +08:00
Yanray Wang
a3841ab299 code_size_compare.py: add missing aes.o in code size comparison
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-05-25 15:51:40 +08:00
Yanray Wang
369cd96176 code_size_compare.py: add suffix to code size report
This commit adds suffix of architecture and configuration to the
file of code size record and comparison result.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-05-25 15:51:40 +08:00
Aditya Deshpande
41a0aad78d code_size_compare.py: clean up worktree in errors of subprocess
With this change, the program cleans up worktree in errors of
execution of subprocess.checkout. Additionally, the error log is
printed out for users.

Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-05-25 15:51:40 +08:00
Yanray Wang
6a86258eab code_size_compare.py: support measurement of tfm-medium
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-05-25 15:51:38 +08:00
Yanray Wang
23bd53239d code_size_compare.py: add --arch and detection of host arch
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-05-25 15:49:54 +08:00
Minos Galanakis
2daa374ea8 ecp_curves: Minor refactoring of mbedtls_ecp_mod_p255_raw()
* Fixed whitespace issues.
* Renamed variables to align with bignum conventions.
* Updated alignment on test input data.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-05-23 09:57:09 +01:00
Minos Galanakis
aada68f1be ecp.py: Fixed types for arguments() overrides.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-05-23 09:57:09 +01:00
Minos Galanakis
c2c967b1f0 ecp.py: Added tests for mbedtls_ecp_mod_p255_raw
This patch introduces the `EcpP255Raw` test class for testing
the curve using the preestablished `ecp_mod_p_generic_raw()`
test. The test's logic has been updated accordingly.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-05-23 09:57:09 +01:00
Paul Elliott
26070670d6
Merge pull request #7565 from gabor-mezei-arm/7263_split_out_Koblitz_raw_functions
[Bignum] Split out _raw Koblitz reduction functions
2023-05-22 16:03:17 +01:00
Gilles Peskine
63df4ec3ca
Merge pull request #7589 from daverodgman/pr4990
Replace references to Mbed Crypto (rebase)
2023-05-16 19:14:51 +02:00
Paul Elliott
f0806bee66
Merge pull request #7489 from minosgalanakis/ecp/7246_xtrack_core_shift_l
[Bignum]: Introduce left shift from prototype
2023-05-16 17:13:19 +01:00
Gabor Mezei
03558b847e
Add _raw function to P256K1
Modified the testing to use the generic fast reduction test function.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-05-16 17:30:03 +02:00
Gabor Mezei
e42bb6294e
Add _raw function to P224K1
Modified the testing to use the generic fast reduction test function.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-05-16 17:30:03 +02:00
Gabor Mezei
dacfe56370
Add _raw function to P192K1
Modified the testing to use the generic fast reduction test function.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-05-16 17:29:57 +02:00
Minos Galanakis
99453ad9f0 bignum_core.py: Simplified result calculation for BignumCoreShiftL
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-05-16 15:28:19 +01:00
Fredrik Hesse
0ec8a90d48 Replace references to Mbed Crypto with Mbed TLS through-out documentation and comments.
Signed-off-by: Fredrik Hesse <fredrik@hesse.se>
2023-05-12 15:00:45 +01:00
Fredrik Hesse
cc207bc379 Replace references to Mbed Crypto with Mbed TLS through-out documentation and comments.
Signed-off-by: Fredrik Hesse <fredrik@hesse.se>
2023-05-12 14:59:01 +01:00
Gabor Mezei
23b10109bb
Add test cases to test overflow in the Kobltz reduction
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-05-12 12:34:12 +02:00
Minos Galanakis
013167ed7f bignum_common.py: Addressed minor typos
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-05-11 10:54:44 +01:00