17697 Commits

Author SHA1 Message Date
Gilles Peskine
f599ddfb43 Remove string hack for mbedtls_mpi_mod_int testing
Now that the test framework can pass arbitrary values of type
mbedtls_mpi_sint, just do that.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
ba72662730 Allow more signed integer types in test function arguments
Now that the C code supports the full range of intmax_t, allow any size of
signed integer type in the .data file parser.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
6494d923f0 Support larger integer test arguments: C part
Change the type of signed integer arguments from int32_t to intmax_t.
This allows the C code to work with test function arguments with a range
larger than int32_t. A subsequent commit will change the .datax generator
to support larger types.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
615be63565 parse_function_arguments: stricter type parsing
Use normalization the equality comparisons instead of loose regular
expressions to determine the type of an argument of a test function.

Now declarations are parsed in a stricter way: there can't be ignored junk
at the beginning or at the end. For example, `long long unsigned int x`
was accepted as a test function argument (but not `long long unsigned x`),
although this was misleading since the value was truncated to the range of
int. Now only recognized types are accepted.

The new code is slightly looser in that it accepts `char const*` as well as
`const char*`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
46476e04f4 Support (void) as an argument list of a test function
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
f153c5676b parse_function_arguments: extract per-argument function
Internal refactoring only, no behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
3a37f19e31 parse_function_arguments: make local_vars a list
Internal refactoring only, no behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
9ad7bd3060 Support different types in the parameter store
The test framework stores size_t and int32_t values in the parameter store
by converting them all to int. This is ok in practice, since we assume int
covers int32_t and we don't have test data larger than 2GB. But it's
confusing and error-prone. So make the parameter store a union, which allows
size_t values not to be potentially truncated and makes the code a little
clearer.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
a299043d58 Simplify parsing of integers in .datax files
In the .datax parser, since we're calling strtol() anyway, rely on it for
verification. This makes the .datax parser very slightly more
liberal (leading spaces and '+' are now accepted), and changes the
interpretation of numbers with leading zeros to octal.

Before, an argument like :0123: was parsed as decimal, but an argument like
:0123+1: was parsed as a C expression and hence the leading zero marked an
octal representation. Now, a leading zero is always interpreted according to
C syntax, namely indicating octal. There are no nonzero integer constants
with a leading zero in a .data file, so this does not affect existing test
cases.

In the .datax generator, allow negative arguments to be 'int' (before, they
were systematically treated as 'exp' even though they didn't need to be).

In the .datax parser, validate the range of integer constants. They have to
fit in int32_t. In the .datax generator, use 'exp' instead of 'int' for
integer constants that are out of range.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
242b05b7b6 Exercise string parsing in the test framework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
1780875e9b Simplify string escapes
Treat backslash as a universal escape character: "\n" is a newline,
backslash escapes any non-alphanumeric character.

This affects some test cases that had "\," standing for backslash-comma.
With the new uniform treatment of backslashes, this needs to be "\\,".

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
ab56a6952b Factor get_function_info out of gen_from_test_data
No intended behavior change. This commit is mainly to satisfy pylint, which
complains that gen_from_test_data now has too many variables. But it's a
good thing anyway to make the function a little more readable.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
f122aedb81 Add line number to a few error messages
This is just a quick improvement, not meant to tackle the problem as a
whole.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
13e836a508 printf testing: exercise integer parsing in the test framework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
af2fc50b76 Remove stdint.h substitute for older MSVC
We now require at least Visual Studio 2013, which has stdint.h per
 https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/y4hta57s(v=vs.120)
so the workaround to define C99 types on pre-C99 MSVC is no longer needed.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
404923e15c Remove declarations of the nonstandard function strcasecmp
It is no longer used.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:27 +02:00
Gilles Peskine
f549d9cb59 Stop supporting non-canonical case in mpi_write_string test data
We're using the non-standard function strcasecmp() just so that the case
of digits beyond 9 can be different in the library and in the test data.
Use matching case in the test data, and use a standard function for the
comparison.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 22:51:10 +02:00
Gilles Peskine
366e6859e3 Remove mbedtls_ prefix from bignum test cases
Align 2.28 with development to make backports easier.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-26 22:51:10 +02:00
Tom Cosgrove
503f487cbe
Merge pull request #7469 from xkqian/2.28/bignumber_update_comments
Backport 2.28: Update links of references in bignum code
2023-04-26 16:22:09 +01:00
Janos Follath
b5b0649e77
Merge pull request #7470 from xkqian/2.28/bignumber_ecp_update
Backport 2.28: Update gen_prvkey_mx paras to align with comments and c code
2023-04-24 13:44:25 +01:00
Manuel Pégourié-Gonnard
c14776c590
Merge pull request #7456 from valeriosetti/issue7446-backport
Backport: Clean up & improve PK write test functions
2023-04-24 13:05:21 +02:00
Valerio Setti
a4d460c99c test_suite_pkwrite: replace memcpy with memmove
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-04-24 10:47:42 +02:00
Valerio Setti
755582b297 fix typos
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-04-24 10:47:36 +02:00
Valerio Setti
3b608de6f3 fix new line difference in Windows
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-04-24 10:47:31 +02:00
Xiaokang Qian
8738bc46e3 Update gen_prvkey_mx paras to align with comments and c code
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-04-21 10:29:17 +00:00
Xiaokang Qian
0e5a27b640 Update links of references in bignum code
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-04-21 09:58:07 +00:00
Valerio Setti
f1477da185 test: pkwrite: backport of issue 7446
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-04-18 16:58:22 +02:00
Dave Rodgman
e323fb3ab5
Merge pull request #7409 from yanesca/lts-lifetime-clarification-2.28
[Backport 2.28] Clarify LTS lifetime
2023-04-17 18:18:25 +01:00
Janos Follath
205c5081d5 Update BRANCHES.md
Co-authored-by: Dave Rodgman <dave.rodgman@arm.com>
Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-04-11 15:21:34 +01:00
Janos Follath
f462d20713
BRANCHES.md: improve wording
Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-04-11 10:15:13 +01:00
Gilles Peskine
b76bcfb228
Merge pull request #7332 from yanrayw/2.28_7285-followup-of-PR6500
Backport 2.28: 6500 follow-up: enhancements to the new ssl_helpers test module #7287
2023-04-11 09:31:41 +02:00
Janos Follath
36c66a87d7 Clarify LTS lifetime
Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-04-05 15:54:10 +01:00
Dave Rodgman
83faeca597
Merge pull request #7386 from daverodgman/timing_alignment-2.28
Backport 2.28 - Timing alignment
2023-03-31 19:48:19 +01:00
Dave Rodgman
2497c6b860 Whitespace fix
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 18:05:19 +01:00
Dave Rodgman
6ab5d5c536 Fix trailing whitespace
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 17:24:10 +01:00
Dave Rodgman
8f109fc249 Fix use of uninitialised variable
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 17:07:04 +01:00
Dave Rodgman
b2e3c7af2d Tidy-up
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 16:43:40 +01:00
Dave Rodgman
3fead76eba Test that setting reset actually does something
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 16:43:34 +01:00
Dave Rodgman
8dde24eb08 Tidy-up
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 16:24:04 +01:00
Dave Rodgman
42a5bb16c6 Fix failure to write back when reset != 0; tidy-up
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 16:20:32 +01:00
Dave Rodgman
0feecbd6f3 Copy the struct to align it, avoiding an ABI break
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 16:10:18 +01:00
Dave Rodgman
1a0a2c6baa Fix cast alignment warning in timing.c
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 11:40:24 +01:00
Manuel Pégourié-Gonnard
616f23e016
Merge pull request #7338 from yanrayw/2.28-6500-gitignore-fix
Backport 2.28: fix: ignore *.o under tests/src/test_helpers
2023-03-30 23:21:53 +02:00
Dave Rodgman
87af9c38d6
Merge pull request #7310 from Mbed-TLS/2.28-sphinx-versioned-documentation
[Backport 2.28] Generate API documentation with Sphinx and Breathe
2023-03-29 14:43:08 +01:00
David Horstmann
4b30783be4 Add _build/ and api/ to gitignore
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-03-28 15:01:34 +01:00
David Horstmann
9a2ddfd147 Clean the breathe-apidoc files with make clean
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-03-28 15:01:34 +01:00
Paul Elliott
640d07e198
Merge pull request #1011 from paul-elliott-arm/mbedtls-2.28.3_mergeback
Mbedtls 2.28.3 merge back
2023-03-28 13:44:34 +01:00
David Horstmann
66ef2a06d5 Revert "Add exemption for make.bat in checks for tabs"
This is no longer needed as make.bat has been removed. We do not support
building the documentation on Windows.

This reverts commit d50daedccace24bf69903ff7879bc0543757f5ef.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-03-27 15:39:13 +01:00
David Horstmann
042d845e08 Remove make.bat for documentation
Building the docs on Windows is not supported in any case, as the apidoc
target in the main Makefile will not run on Windows.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-03-27 15:39:13 +01:00
David Horstmann
1c40d751b4 Improve docs Makefile to do full build
Include the make apidoc and breathe-apidoc steps in the documentation
Makefile for ease of use. In this way, depart from the Makefile
generated automatically by Sphinx.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-03-27 15:39:13 +01:00