17753 Commits

Author SHA1 Message Date
Dave Rodgman
bd77182063 Make use of MBEDTLS_STATIC_ASSERT
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-16 16:47:09 +01:00
Dave Rodgman
001917898f Document minimum size for DEBUG_BUF_SIZE
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-16 16:47:09 +01:00
valord577
0d87d90cea simplify code
Signed-off-by: valord577 <valord577@gmail.com>
2023-05-16 16:47:09 +01:00
valord577
de6ea9847d code style
Signed-off-by: valord577 <valord577@gmail.com>
2023-05-16 16:47:09 +01:00
valord577
06b0bb55e3 make code readable and change var name
Signed-off-by: valord577 <valord577@gmail.com>
2023-05-16 16:47:09 +01:00
valord577
e3623920cf send debug msg if contains '\n'
Signed-off-by: valord577 <valord577@gmail.com>
2023-05-16 16:47:09 +01:00
Dave Rodgman
40fe1cd364 Update library/debug.c
Fix trailing white-space

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-16 16:47:09 +01:00
valord577
afbaac29e8 Fix: no newline when debug msg over DEBUG_BUF_SIZE
Signed-off-by: valord577 <valord577@gmail.com>
2023-05-16 16:47:09 +01:00
Paul Elliott
9febc989c7
Merge pull request #7587 from gilles-peskine-arm/gitignore-objects-at-root-2.28
Backport 2.28: Ignore *.o everywhere
2023-05-15 13:57:12 +01:00
Gilles Peskine
e32e447407 Ignore *.o everywhere
We don't commit *.o files anywhere, not even as test data. So ignore them
everywhere.

Also remove a redundant ignore of *.exe in a subdirectory.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-05-12 13:57:39 +02:00
Gilles Peskine
a8b3d0c7a2
Merge pull request #7553 from davidhorstmann-arm/2.28-remove-doxygen-mainpage-content
[Backport 2.28] Remove API docs mainpage content
2023-05-07 20:35:31 +02:00
David Horstmann
73474ed121 Minor cosmetic changes
* Change "source code documentation" to "API documentation" for
precision
* Change "mbed TLS" to "Mbed TLS" following established convention
* Use title case in the title

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-05-04 15:36:23 +01:00
David Horstmann
1ef4dc9df9 Update broken link to doxygen homepage
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-05-04 15:35:10 +01:00
David Horstmann
07b1cf91e1 Remove most of the doxygen mainpage
Since the API docs are now published as part of the larger
documentation, it makes no sense to give an overview of Mbed TLS in the
mainpage as this is already given elsewhere.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-05-04 15:35:08 +01:00
Dave Rodgman
2e4541f96f
Merge pull request #7545 from tom-cosgrove-arm/use-mbedtls_ct_uint_if-rather-than-mbedtls_ct_cond_select_sign-2.28
Backport 2.28: Use mbedtls_ct_uint_if() rather than mbedtls_ct_cond_select_sign()
2023-05-04 12:23:36 +01:00
Gilles Peskine
5ead738269
Merge pull request #7503 from gilles-peskine-arm/test-argument-types-union-2.28
Backport 2.28: Support larger integer test arguments
2023-05-04 10:05:25 +02:00
Paul Elliott
d7570a2a3b
Merge pull request #7536 from valeriosetti/issue7480-backport
Backport: Fix test gap in PK write: private (opaque) -> public
2023-05-03 17:08:43 +01:00
Tom Cosgrove
735d2c99e7 Backport 2.28: Use mbedtls_ct_uint_if() rather than mbedtls_ct_cond_select_sign()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-05-03 09:50:10 +01:00
Valerio Setti
0eace4128b pk: fixing backport issues
Note: RSA is not supported in mbedtls-2.28 for opaque wrapping
so it was removed from test_suite_pkwrite.data.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 16:38:57 +02:00
Valerio Setti
974b816b3e test: check for exact length of returned pub key
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 16:06:40 +02:00
Valerio Setti
3f8bf06534 test: optimize code for pk_write_public_from_private()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 16:06:39 +02:00
Valerio Setti
39a669433b test: use better naming for the newly introduced test function
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 16:06:36 +02:00
Valerio Setti
5e7494ea75 pk: fix position for mbedtls_platform_zeroize
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 16:06:34 +02:00
Valerio Setti
b4468c45ac test: fix makefile for ec_pub.[der/pem] generation
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 16:04:46 +02:00
Valerio Setti
50dacdfd34 test: fix wrong private key file
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 16:00:58 +02:00
Valerio Setti
7406e967f0 test: add test function for public key derivation starting from private one
Data test cases are also included in the commit.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 16:00:53 +02:00
Valerio Setti
aae96c9060 pk: fix: clear buffer holding raw EC private key on exit
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 16:00:45 +02:00
Manuel Pégourié-Gonnard
c69614bec0
Merge pull request #7505 from valeriosetti/issue7460-part1-backport
Backport: Fixing USE_PSA_INIT/DONE in SSL/X509/PK test suites
2023-05-02 10:44:15 +02:00
Gilles Peskine
dca0501089 Adjust code style for pointer types and casts
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
47903b17e9 typo
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
97f5cff2a2 Add test cases with a question mark
The test framework used to treat them specially (but no longer does). Add
these test cases as non-regression for how the test framework allows "?"
and especially "??" (which I think in the very distant path needed special
handling because the test data was embedded in a .c file, and thus ?? could
be interpreted as the prefix of a trigraph).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
5be40834e4 Fix wrong comment
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
f089972625 Explain the format argument expected by the test functions
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
c2fda4b7fb Fix typos in test descriptions
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
Gilles Peskine
c627917439 Test the line number returned by parse_test_data
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-04-28 13:19:30 +02:00
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