Commit graph

8048 commits

Author SHA1 Message Date
Janos Follath
87df373e0e Bignum test: Move identical function to superclass
No intended change in generated test cases.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-21 08:56:13 +00:00
Janos Follath
0cd8967ba1 Split test generator base class
The class BaseTarget served two purposes:
- track test cases and target files for generation
- provide an abstract base class for individual test groups

Splitting these allows decoupling these two and to have further common
superclasses across targets.

No intended change in generated test cases.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-21 08:56:13 +00:00
Jerry Yu
dddd35ccf3 remvoe unrelative change
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-11-20 12:31:45 +08:00
Jerry Yu
a8d3c5048f Rename new session ticket name for TLS 1.3
NewSessionTicket is different with TLS 1.2.
It should not share same state.

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-11-19 20:12:35 +08:00
Jerry Yu
c5826eaba2 Add debug message
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-11-19 20:12:35 +08:00
Jerry Yu
6969eee5d2 Remove Terminated message on 22.04
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-11-19 20:12:34 +08:00
Gilles Peskine
9ac62c3a97 Explain space preservation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-18 22:27:37 +01:00
Gilles Peskine
268ea5a9b0 Typos in comments
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-18 22:26:03 +01:00
Gilles Peskine
45747a0779 Add test cases for comment nesting
Add a test case that would fail if all line comments were parsed before
block comments, and a test case that would fail if all block comments were
parsed before line comments.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-18 22:25:18 +01:00
Gilles Peskine
18f48eb48e Fix intended backslash in test data
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-18 22:24:56 +01:00
Xiaokang Qian
4e83173bb7 Skip early data basic check temp
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-11-18 10:57:46 +00:00
Manuel Pégourié-Gonnard
ba7c006222
Merge pull request #6466 from mprse/driver-only-hash-ci
Driver-only hashes: test coverage in the CI
2022-11-18 09:31:13 +01:00
Paul Elliott
f6e342cae2 Add test for single signature alg with openssl
Test supplied by Gilles Peskine. Also rename previous test to fit to
naming pattern.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2022-11-17 14:58:14 +00:00
Paul Elliott
3b4cedaa71 Add SSL_SRV requirement to test
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2022-11-17 14:58:14 +00:00
Andrzej Kurek
ec71b0937f Introduce a test for single signature algorithm correctness
The value of the first sent signature algorithm is overwritten.
This test forces only a single algorithm to be sent and then
validates that the client received such algorithm.
04 03 is the expected value for SECP256R1_SHA256.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-11-17 14:58:14 +00:00
Ronald Cron
d12922a69a
Merge pull request #6486 from xkqian/tls13_add_early_data_indication
The merge job of the internal CI ran successfully. This is good to go.
2022-11-17 12:48:50 +01:00
Przemek Stekiel
85c54ea361 Allow providing space sepatated tasks
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-17 11:50:23 +01:00
Xiaokang Qian
e9622ac4ba Remove the fore_tls13 option case from client side
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-11-17 09:23:32 +00:00
Tom Cosgrove
8c0eb9744c Must call mbedtls_mpi_mod_modulus_init() before anything else in tests
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-11-17 08:48:12 +00:00
Przemek Stekiel
542d932352 Fix handling of default value for task argument
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-17 09:43:34 +01:00
Przemek Stekiel
7c7954842b Adapt ec-jpake_setup test
Now when operation holds pointer to dynamically allocated buffer for password key we can't do copy of the operation object in test instead we need to re-initialize operation object after error.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-16 16:27:55 +01:00
Przemek Stekiel
6419ab5299 Reduce number of skipped suites (after making configs more similar)
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-16 14:56:49 +01:00
Przemek Stekiel
52d8e96ff6 Disable PSA_WANT_ALG_STREAM_CIPHER, PSA_WANT_ALG_ECB_NO_PADDING also in reference config
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-16 14:56:26 +01:00
Przemek Stekiel
f3be7ccade Keep drivers enabled also in reference build
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-16 12:53:20 +01:00
Xiaokang Qian
e7bab00825 Update enabled guards for early data cases
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-11-16 10:06:50 +00:00
Xiaokang Qian
f3cefb4f4c Move early data test cases to tls13-misc.sh
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-11-16 03:23:46 +00:00
Xiaokang Qian
2dbfedae4a Update early data test cases with latest code message
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-11-16 02:01:49 +00:00
Gilles Peskine
298f781948 Use .datax for make test, not .data
Looking for the .data file doesn't work in out-of-tree builds. Use the
.datax file instead. `make clean` removes all .datax files, so this resolves
the issue of executables not present on the current branch being left behind
after a branch change followed by a `make clean`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-15 23:54:26 +01:00
Gilles Peskine
af601f9751 Fix undefined behavior with the most negative mbedtls_mpi_sint
When x is the most negative value of a two's complement type,
`(unsigned_type)(-x)` has undefined behavior, whereas `-(unsigned_type)x`
has well-defined behavior and does what was intended.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-15 23:02:14 +01:00
Gilles Peskine
23875ceb11 Fix autocucumber in documentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-15 20:49:58 +01:00
Gilles Peskine
b9b9026c53 Pacify pylint
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-15 20:49:43 +01:00
Gilles Peskine
35af02171d Add negative zero as an input to automatically generated tests
Although negative zero is officially unsupported, we've had bugs related to
it in the past. So do test functions with a negative zero input.

There will likely be cases where we don't want to accept negative zero as if
it was valid, because it's too hard to handle. We'll add exceptions on a
case by case basis.

For the functions that are currently tested by the generated tests, the new
test cases pass.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-15 20:47:07 +01:00
Gilles Peskine
ca6e8aac58 Support negative zero as MPI test input
The bignum module does not officially support "negative zero" (an
mbedtls_mpi object with s=-1 and all limbs zero). However, we have a
history of bugs where a function that should produce an official
zero (with s=1), produces a negative zero in some circumstances. So it's
good to check that the bignum functions are robust when passed a negative
zero as input. And for that, we need a way to construct a negative zero
from test case arguments.

There are checks that functions don't produce negative zeros as output in
the test suite. Skip those checks if there's a negative zero input: we
don't want functions to _create_ negative zeros, but we don't mind if
they _propagate_ negative zeros.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-15 20:47:07 +01:00
Valerio Setti
9f0ec53c4c add a test for EC-JPAKE compatibility in TLS1.2
This is to ensure that the MbedTLS based implementation of EC-JPAKE
is compatible with the PSA crypto one

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2022-11-15 16:49:55 +01:00
Przemek Stekiel
aa88e0b86b Make configurations (driver, reference) as close as possible
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-15 13:21:14 +01:00
Gilles Peskine
2909f53740
Merge pull request #6604 from tom-cosgrove-arm/call-mbedtls_mpi_mod_modulus_init-first-cid-381893-381894
Bignum: Must call mbedtls_mpi_mod_modulus_init() before anything else in tests
2022-11-15 12:33:13 +01:00
Manuel Pégourié-Gonnard
edce0b42fb
Merge pull request #6454 from valeriosetti/issue4577
Adding unit test for mbedtls_x509write_csr_set_extension()
2022-11-15 09:39:07 +01:00
Tom Cosgrove
f90111b2b5 Must call mbedtls_mpi_mod_modulus_init() before anything else in tests
Fixes (new) Coverity issues 381893 and 381894

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-11-15 06:15:15 +00:00
Xiaokang Qian
9a0aafbe79 Enable/disable MBEDTLS_SSL_EARLY_DATA for cases in ssl-opt.sh
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-11-15 02:49:46 +00:00
Dave Rodgman
d384b64dd2
Merge branch 'development' into rfc9146_2
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-14 17:43:15 +00:00
Przemek Stekiel
d3068af2a8 Optimize code (tasks list initialization, task verification)
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-14 16:15:19 +01:00
Valerio Setti
48e8fc737a Adding unit test for mbedtls_x509write_csr_set_extension()
The already existing "x509_csr_check()" function is extended in order
to support/test also CSR's extensions. The test is performed by
adding an extended key usage.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2022-11-14 13:32:07 +01:00
Janos Follath
1b9cb62702
Merge pull request #6573 from tom-cosgrove-arm/convert-mpi_mod_int-test-cases-to-hex
Enable mpi_mod_int test case to take full-range MPI integers
2022-11-14 12:04:09 +00:00
Janos Follath
4d0ea7f4cc
Merge pull request #6550 from minosgalanakis/minos/6017_add_montgomery_conversion
Bignum: Add Montgomery conversion from/to cannonical form
2022-11-14 11:12:13 +00:00
Przemek Stekiel
8b6826d309 Revert "Add fake dependency to test CI"
This reverts commit a380b06c26.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-14 08:34:48 +01:00
Przemek Stekiel
733c76e08a Fix style issues pointed by pylint
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-14 08:33:21 +01:00
Xiaokang Qian
402bb1ee90 Update documents and check
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-11-14 03:16:22 +00:00
Xiaokang Qian
50a47940b6 Update early data test case with gnutls
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-11-14 03:16:22 +00:00
Xiaokang Qian
f447e8a8d3 Address comments base on reviews
Improve early data indication check
Update test case to gnutls server

Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-11-14 03:15:36 +00:00
Xiaokang Qian
b0c32d8b20 Update early data test cases
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-11-14 03:15:05 +00:00
Xiaokang Qian
0e97d4d16d Add early data indication to client side
Add fields to mbedtls_ssl_context
Add write early data indication function
Add check whether write early data indication
Add early data option to ssl_client2
Add test cases for early data

Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-11-14 03:13:50 +00:00
Paul Elliott
aeb8bf2ab0
Merge pull request #6170 from yuhaoth/pr/tls13-cleanup-extensions-parser
TLS 1.3: Add extension check for message parsers
2022-11-11 19:00:46 +00:00
Gilles Peskine
07510f5ba3 Allow comments in prototypes of unit test functions
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-11 16:37:16 +01:00
Gilles Peskine
0cf42200fa Fix typo and copypasta
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-11 16:36:51 +01:00
Minos Galanakis
47691fb756 bignum_tests: Refactored mpi_mod_raw_to/fromt_mont_rep
This patch migrates the tests to use the `mbedtls_test_read_mpi_core()`.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-11-11 10:55:08 +00:00
Minos Galanakis
df070d660d bignum_tests: Added test for mbedtls_mpi_mod_raw_from_mont_rep()
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-11-11 10:55:08 +00:00
Minos Galanakis
631b491cbf bignum_tests: Added test for mbedtls_mpi_mod_raw_to_mont_rep()
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-11-11 10:55:08 +00:00
Dave Rodgman
71565cff3a Disable PKCS7 for some TLS 1.3 tests
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-11 10:37:38 +00:00
Gilles Peskine
1d7cc08af1 Add target to generated all .c (and .datax) files
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-10 19:52:28 +01:00
Gilles Peskine
0c3f5f1471 Remove some Python 2 compatibility code
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-10 19:52:28 +01:00
Dave Rodgman
ebd0caffdf Fix test memory allocation
Fix error in memory allocation in test code, which was triggering an
error in test_memory_buffer_allocator.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-10 15:33:54 +00:00
Tom Cosgrove
163d8952b3 Add additional (would fail) test cases for mpi_mod_int with 0 remainder
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-11-10 12:17:36 +00:00
Tom Cosgrove
9feb19f98d Use mbedtls_mpi_sint not mbedtls_mpi_uint in mpi_mod_int test
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-11-10 12:05:55 +00:00
Minos Galanakis
5566eff657 generate_bignum_tests: Enabled BignumModRaw automatic generation
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-11-10 11:37:33 +00:00
Gilles Peskine
b4eb444a5c
Merge pull request #6535 from davidhorstmann-arm/change-test-templating-syntax
Change test templating syntax to be valid C
2022-11-10 12:05:55 +01:00
Dave Rodgman
f58172fe43 Merge remote-tracking branch 'origin/development' into pr3431 2022-11-10 09:54:49 +00:00
Gilles Peskine
9a571ddfd9
Merge pull request #6543 from mpg/improve-test-suites-listing
Improve test suite detection in run-test-suites.pl
2022-11-09 19:03:03 +01:00
Gilles Peskine
ed4b34aa7c
Merge pull request #6570 from gilles-peskine-arm/bignum-mbedtls_test_read_mpi_core-nonempty
Forbid empty mpi_core in test data
2022-11-09 19:02:24 +01:00
David Horstmann
360f8e4429 Minor improvements to test code script
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-09 17:27:33 +00:00
Nick Child
89e82e1685 pkcs7: Add dependecy on MBEDTLS_MD_C
Signed-off-by: Nick Child <nick.child@ibm.com>
2022-11-09 10:36:10 -06:00
Jerry Yu
97be6a913e fix various issues
- typo error
- replace `ssl->hanshake` with handshake

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-11-09 22:43:31 +08:00
Przemek Stekiel
992de3c562 Make TASK parameter positional and allow more than one task
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-09 14:24:49 +01:00
Tom Cosgrove
91e35e3c32 Enable mpi_mod_int test case to take full-range MPI integers
Also add commented-out test cases that currently fail

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-11-09 11:45:29 +00:00
Przemek Stekiel
be279c7bcc Make a list from ignored tests in TASKS
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-09 12:17:08 +01:00
Przemek Stekiel
51f30ff6e6 Make separate components for ref and driver in TASKS
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-09 12:07:29 +01:00
Manuel Pégourié-Gonnard
b9581824f7
Merge pull request #6561 from AndrzejKurek/ecjpake-error-injection
Improve error injection in EC J-PAKE tests
2022-11-09 11:48:36 +01:00
Gilles Peskine
95b5addcd6 Don't test mbedtls_mpi_core_lt_ct with 0 limbs
A core MPI must have at least 1 limb. We can no longer test with 0 limbs,
and we don't need to anyway, so don't try.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-09 11:18:38 +01:00
Przemek Stekiel
6856f4c70d Fix typos and comments
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-11-09 10:50:29 +01:00
Gilles Peskine
0b7e07904e Forbid empty mpi_core in test data
This way static analyzers have a chance of knowing we don't expect the
bignum functions to support empty inputs. As things are, Coverity keeps
complaining about it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-09 10:45:15 +01:00
Gilles Peskine
4a480ac5a1
Merge pull request #6265 from Kabbah/x509-info-hwmodulename-hex
`x509_info_subject_alt_name`: Render HardwareModuleName as hex
2022-11-08 17:11:07 +01:00
Jerry Yu
616ba75c23 move test cases and mark tls13-kex-modes.sh as locked
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-11-08 23:51:39 +08:00
Aditya Deshpande
c4646c08cd Merge branch 'development' into driver-wrapper-key-agreement 2022-11-08 14:25:20 +00:00
Andrzej Kurek
c018204019 Improve error injection in EC J-PAKE tests
Instead of corrupting the public key part of the message,
corrupt the proof part. A proof is conceptually similar to a signature,
and changing anything in it should make it invalid with 
a high probability.
Also, instead of shifting data, perform a bitflip.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-11-08 08:12:56 -05:00
Pengyu Lv
14a87291bd fix false negative reported by check_names.py
The PSA_CRYPTO_C is excluded from typo check for the following
false negative report:

```
  > include/mbedtls/check_config.h:329: 'PSA_CRYPTO_C' looks like a typo. It
    was not found in any macros or any enums. If this is not a typo, put //no-
    check-names after it.
    |
329 |  * Note: ECJPAKE_C depends on MD_C || PSA_CRYPTO_C. */
    |                                       ^^^^^^^^^^^^

```

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2022-11-08 19:41:28 +08:00
Gilles Peskine
42d75f2daf
Merge pull request #6013 from gstrauss/asn1-type-free
Shared code to free x509 structs like mbedtls_x509_named_data
2022-11-08 12:20:20 +01:00
Gilles Peskine
433f1f1809
Merge pull request #6456 from gabor-mezei-arm/6237_test_update_cond_assign_swap
Update tests to use conditional assign and swap
2022-11-08 12:15:07 +01:00
Aditya Deshpande
98061a75a1 Add default return case to mbedtls_test_transparent_key_agreement()
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-11-08 10:37:01 +00:00
Pengyu Lv
f3f1f81c1a add exclusive rule for PSA_CRYPTO_DRIVER_TEST
This macro is expected to be defined out of the library, and there
is no definition in the library. Thus it needs to be excluded from
typo check.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2022-11-08 18:22:53 +08:00
Pengyu Lv
cdac0d5305 check_names: extend typo check to PSA macro/enum names
Typos of PSA macro and enum names are not checked by check_names.py.
This commit extend the check list to include PSA_XXX references.
The words should be macro/enum names defined as public_macros,
internal_macros, private_macros and enums. This commit alse extend
the scope of enums to include those are defined in library/*.c.
A new type of macros "private", which are defined in library/*.c was
also added.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2022-11-08 18:22:53 +08:00
Jerry Yu
e5991328ff fix tls13 psk only test fail
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-11-08 16:16:29 +08:00
Glenn Strauss
2a64299648
Update tests/suites/test_suite_asn1parse.function
Co-authored-by: Andrzej Kurek <andrzej.kurek@arm.com>
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
2022-11-07 20:09:38 -05:00
Glenn Strauss
aa36c2a6f6
Update tests/suites/test_suite_asn1parse.function
Co-authored-by: Andrzej Kurek <andrzej.kurek@arm.com>
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
2022-11-07 20:08:54 -05:00
Glenn Strauss
82ba274c01 Deprecate mbedtls_asn1_free_named_data()
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
2022-11-07 15:42:44 -05:00
Aditya Deshpande
d1b72a7b83 Merge branch 'development' into driver-wrapper-key-agreement 2022-11-07 17:36:23 +00:00
Aditya Deshpande
ec6bb5879a Disabled tests in test_suite_ssl that won't work without builtin ECDH
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-11-07 17:11:48 +00:00
Gilles Peskine
faefe62013
Merge pull request #6390 from mpg/fix-ecjpake-psa-format
Fix ecjpake PSA format
2022-11-07 17:35:44 +01:00
Gilles Peskine
bf249accc7
Merge pull request #6498 from yuhaoth/pr/fix-session-resumption-fail-when-hostname-is-not-localhost
BUG: Fix session resumption fail when hostname is not localhost
2022-11-07 17:33:38 +01:00
Gilles Peskine
34c09469f3
Merge pull request #5396 from SiliconLabs/codegen_1.1
Driver dispatch Codegen 1.1
2022-11-07 15:27:41 +01:00
Gabor Mezei
a8cf998bc9
Let the allocated memory visible for the memory sanitizer
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-11-07 15:14:49 +01:00
Gabor Mezei
7ba7b3aded
Update tests to use mbedtls_test_read_mpi_core
In conditional assign and swap tests use the mbedtls_test_read_mpi_core
function for reading MPIs.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-11-07 15:14:49 +01:00
Aditya Deshpande
5567c660cd Fix formatting and code comments
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-11-07 10:43:29 +00:00
Aditya Deshpande
3f1606a1f6 Refactor call hierarchy for ECDH so that it goes through the driver wrapper in a similar fashion to ECDSA.
Add component_test_psa_config_accel_ecdh to all.sh to test key agreement driver wrapper with libtestdriver1.

Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-11-07 09:22:52 +00:00
Manuel Pégourié-Gonnard
38860e2f19 Improve test suite detection in run-test-suites.pl
Looking for executables causes problems with leftover compiled test
suites from other branches when we forget to run make clean before
switching branches. Using the .data files is more robust as most of them
are tracked, so will be removed when switching branches.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-11-07 10:05:49 +01:00
Jerry Yu
f467d46bbb move get_srv_psk_list
It can be reused in other test-suites

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-11-07 13:17:08 +08:00
David Horstmann
b85838f2f4 Change test templating syntax to be valid C
For the benefit of auto-formatting tools, move from the '$placeholder'
templating syntax to a new syntax of the form:

__MBEDTLS_TEST_TEMPLATE__PLACEHOLDER

This change allows the test code template to be almost entirely valid C.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-04 19:53:39 +00:00
Dave Rodgman
2364aaefa6
Update tests/suites/test_suite_pkcs7.function
Address test dependency issue

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-04 11:33:04 +00:00
Nick Child
fc234b7b52 test/pkcs7: Add Windows CRLF EOF to data files
Windows tests are failing pkcs7 verification due to differnt line
endings. Therefore, add make instuctions for building the data
files with Windows EOF instead. As a result, regenerate other data
files so that verification works.

Add these CRLF EOF files to the exception in check_files to ignore
the line endings.

Signed-off-by: Nick Child <nick.child@ibm.com>
2022-11-03 09:24:20 -05:00
Janos Follath
c1a81bc998 Remove trailing new lines
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-02 17:33:11 +00:00
Janos Follath
6642cafae3 Fix merge separator position
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-02 17:28:39 +00:00
Janos Follath
be13652296 Use comments for merge separators in .data files
We do have a comment syntax for .data files, there is no need for dummy
test cases.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-02 17:28:37 +00:00
Janos Follath
5933f691a2 Add merge slots to Bignum files
Legacy Bignum is excluded as it doesn't get regular extensions like new
ones.

Each slot uses comments of their respective filetype. Since .data files
don't have a syntax for comments, dummy test cases are used. (These test
cases will never be executed and no noise will be added to tests.)

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-02 17:27:25 +00:00
Gilles Peskine
dd54324765 Increase iterations for some statistical tests
I ran into a sequence where the assertion `stats[8] > 0` failed for the
range 1..272 with 100 iterations.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-02 16:00:01 +01:00
Gilles Peskine
5980f2bd36 Implement mbedtls_mpi_core_fill_random
Turn mpi_fill_random_internal() into mbedtls_mpi_core_fill_random(). It
had basically the right code except for how X is passed to the function.

Write unit tests.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-02 15:59:36 +01:00
Janos Follath
f1ed5815ba
Merge pull request #6512 from yanesca/extract_uint_table_lookup_core
Implement mbedtls_mpi_core_ct_uint_table_lookup()
2022-11-02 13:58:19 +00:00
Janos Follath
28f85e6683 Fix const time in mpi_core_ct_uint_table_lookup test
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-02 10:20:35 +00:00
Janos Follath
ef67d38bc0 Fix memory leak in mpi_core_ct_uint_table_lookup test
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-10-31 15:11:49 +00:00
Dave Rodgman
55fd0b9fc1
Merge pull request #6121 from daverodgman/pr277
cert_write - add a way to set extended key usages - rebase
2022-10-31 13:27:49 +00:00
Dave Rodgman
7d8b3c9342
Merge pull request #6510 from gilles-peskine-arm/all.sh-simplify-20221028-development
Remove a few redundancies from all.sh
2022-10-31 12:00:18 +00:00
Janos Follath
133f4e427b Test mpi_core_table_lookup for constant timeness
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-10-31 11:32:55 +00:00
Janos Follath
032924f297 Add mbedtls_mpi_core_ct_uint_table_lookup tests
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-10-31 11:32:55 +00:00
Janos Follath
2dc2757cca
Merge pull request #6457 from minosgalanakis/minos/6017_update_modulus_lifecycle
Bignum: Updated the modulus lifecyle
2022-10-31 11:28:37 +00:00
Dave Rodgman
1a22bef116
Merge pull request #6190 from daverodgman/invalid-ecdsa-pubkey
Improve ECDSA verify validation
2022-10-31 09:37:26 +00:00
Gilles Peskine
da6017cbe3 Group cpp_dummy_build test into an existing component
No need to do yet another build just to compile an additional trivial program.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-30 21:18:14 +01:00
Gilles Peskine
78e06a1054 Remove redundant TLS 1.3 components
* component_test_tls13_with_padding: just explicitly sets some options that
  are identical with full.
* component_test_tls13_with_ecp_restartable: redundant since TLS 1.3 doesn't
  have any support for restartable ECC.
* component_test_tls13_with_everest: not useful since TLS 1.3 doesn't call
  ECDH directly, it just relies on the PSA abstraction.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-29 17:57:18 +02:00
Gilles Peskine
8a4fd0e7a9 Remove redundant build-only driver interface component
component_build_psa_accel_alg_ecdsa is subsumed by
component_test_psa_crypto_config_accel_ecdsa, which has the same
configuration and additionally runs the unit tests.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-29 17:51:19 +02:00
Gilles Peskine
4bb369c4eb Always enable MBEDTLS_TEST_HOOKS in TLS 1.3-only test configurations
MBEDTLS_TEST_HOOKS is not supposed to change the behavior of the library, so
it's generally good to have it on in functional tests.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-29 17:48:20 +02:00
Glenn Strauss
a4b4041219 Shared code to free x509 structs
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
2022-10-28 12:51:35 -04:00
Nick Child
73621ef0f0 pkcs7: Improve verify logic and rebuild test data
Various responses to feedback regarding the
pkcs7_verify_signed_data/hash functions. Mainly, merge these two
functions into one to reduce redudant logic [1]. As a result, an
identified bug about skipping over a signer is patched [2].

Additionally, add a conditional in the verify logic that checks if
the given x509 validity period is expired [3]. During testing of this
conditional, it turned out that all of the testing data was expired.
So, rebuild all of the pkcs7 testing data to refresh timestamps.

[1] https://github.com/Mbed-TLS/mbedtls/pull/3431#discussion_r999652525
[2] https://github.com/Mbed-TLS/mbedtls/pull/3431#discussion_r997090215
[3] https://github.com/Mbed-TLS/mbedtls/pull/3431#discussion_r967238206
Signed-off-by: Nick Child <nick.child@ibm.com>
2022-10-28 11:24:25 -05:00
Ronald Cron
04e2133f45
Merge pull request #6482 from ronald-cron-arm/tls13-misc
TLS 1.3: Update documentation for the coming release and misc
2022-10-28 11:09:03 +02:00
Dave Rodgman
f00466e2e0 Build fix - remove line of dead code
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-10-28 09:22:28 +01:00
Jerry Yu
ad9e99bd2e fix session resumption fail when hostname is not localhost
Change-Id: Icb2f625bb11debb5c7cae36e34d7270f7baae4d5
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-10-28 12:30:58 +08:00
Minos Galanakis
0c61a749b7 test_suite_bignum_mod_raw: Removed parameter for mbedtls_mpi_mod_modulus_setup()
This patch updates the tests `mpi_mod_raw_cond_swap()` &
`mpi_mod_raw_cond_assign()` to use a non-zero modulus
when invoking `mbedtls_mpi_mod_modulus_setup()`

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-10-28 00:11:19 +01:00
Dave Rodgman
683850b416
Update tests/suites/test_suite_ecdsa.function
Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-10-27 20:24:46 +01:00
Minos Galanakis
4d4c98b1b9 bignum_mod: mbedtls_mpi_mod_modulus_setup() refactoring.
This patch addresses more review comments, and fixes
a circular depedency in the `mbedtls_mpi_mod_modulus_setup()`.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-10-27 17:47:26 +01:00
Przemek Stekiel
a380b06c26 Add fake dependency to test CI
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-27 14:15:26 +02:00
Minos Galanakis
771c47055f bignum_mod: Style changes
This patch addresses review comments with regards to style of
`mbedtls_mpi_mod_modulus_setup/free()`.

It also removes a test check which was triggering a use-after-free.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-10-27 12:36:24 +01:00
Minos Galanakis
dd365a526f test_suite_bignum: Updated mpi_mod_setup() test
This patch updates the `mpi_mod_setup()` test suite
to check for incosistencies in the montgomery constant
data's lifecycle.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-10-27 11:43:54 +01:00
Gilles Peskine
9603daddaa
Merge pull request #6230 from tom-cosgrove-arm/issue-6223-core-add
Bignum: extract core_add from the prototype
2022-10-27 11:25:27 +02:00
Dave Rodgman
4e0fca3737 Fix test dependency on DTLS connection ID
Ensure MBEDTLS_SSL_DTLS_CONNECTION_ID and MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT
are unset when MBEDTLS_SSL_PROTO_DTLS is not set in tls13-only tests.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-10-27 09:47:21 +01:00
Przemek Stekiel
120ed8f8fa Add comments to explan the purpose of the reference component
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-27 10:29:15 +02:00
Przemek Stekiel
5f6f32a0ad Remove hidden option to skip ssl-opt and compat tests
Also remove compat tests from reference component as results from this run are not included in outcome file.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-27 08:24:43 +02:00
Gilles Peskine
88f5fd9099
Merge pull request #6479 from AndrzejKurek/depends-py-no-psa
Enable running depends.py in a configuration without MBEDTLS_USE_PSA_CRYPTO and remove perl dependency scripts
2022-10-26 20:02:57 +02:00
Dave Rodgman
1df7070acc Fix all.sh dependency on DTLS connection ID
Ensure MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT is unset where
MBEDTLS_SSL_DTLS_CONNECTION_ID is unset.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-10-26 17:08:54 +01:00
Przemek Stekiel
4d13c833da analyze_outcomes.py: remove components and ignore parameters
Use a dictionary to specify optional parameters for each task.
If the task is not specified then all tasks are executed.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-26 16:12:01 +02:00
Ronald Cron
c9176a03a7
Merge pull request #6410 from gilles-peskine-arm/psa-pkparse-pkwrite-3.2
PSA with RSA requires PK_WRITE and PK_PARSE
2022-10-26 14:57:36 +02:00
Gilles Peskine
d4d080b41b
Merge pull request #6407 from minosgalanakis/minos/6017_add_montgomery_constant_squared
Bignum: Added pre-calculation of Montgomery constants
2022-10-26 14:28:16 +02:00
Ronald Cron
4f7feca0dc
Merge pull request #6391 from davidhorstmann-arm/fix-x509-get-name-cleanup
The Open CI ran successfully thus I think we can ignore the internal CI.
2022-10-26 14:27:54 +02:00
Andrzej Kurek
29c002ebdf Remove unused perl dependency scripts
curves.pl, depends-hashes.pl, key-exchanges.pl and depends-pkalgs.pl are now superseded by depends.py.
Update all references to them accordingly.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-26 08:26:58 -04:00
Andrzej Kurek
7cb0077c5d Add all.sh components running depends.py without MBEDTLS_USE_PSA_CRYPTO
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-26 08:26:58 -04:00
Manuel Pégourié-Gonnard
3e0ea98b7c
Merge pull request #6451 from mpg/fix-can-exercise
Fix can_exercise() for RSA and hashes
2022-10-26 10:18:52 +02:00
Gilles Peskine
b06f0717b3 PSA service config build: disable more modules not used by PSA
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-25 21:06:11 +02:00
Gilles Peskine
649e04e3d1 PSA service config build: note why we aren't disabling cipher and md
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-25 21:05:57 +02:00
Gilles Peskine
1f10807837 Disable pk in the PSA service config build
It's not needed as a feature. It gets reenabled automatically in
build_info.h like pk_write and pk_parse, but that's an implementation
detail.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-25 21:02:56 +02:00
Gilles Peskine
78bffd1ff5 Fix spelling of a disabled option
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-25 21:02:33 +02:00
Ronald Cron
eac00ad2a6 tls13: server: Note down client not being authenticated in SSL context
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-25 20:02:03 +02:00
Ronald Cron
a709a0f2c6 tls13: Declare PSK ephemeral key exchange mode first
In the PSK exchange modes extension declare first
PSK ephemeral if we support both PSK ephemeral
and PSK. This is aligned with our implementation
giving precedence to PSK ephemeral over pure PSK
and improve compatibility with GnuTLS.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-25 19:05:26 +02:00
Tom Cosgrove
93003d87a9 Split out testing of core_add and core_add_if per Janos' request
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-10-25 17:01:19 +01:00
Minos Galanakis
37ca3a9acd Moved tests from test_suite_bignum to test_suite_bignum_core
This patch moves the following tests to test_suite_bignum_core:
* `mbedtls_mpi_core_get_mont_r2_unsafe_neg()`
* `mbedtls_mpi_core_get_mont_r2_unsafe()`

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-10-25 16:56:08 +01:00
Ronald Cron
dd0c8f9c26 tls13-kex-modes.sh: Remove unnecessary GnuTLS option
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-25 17:35:50 +02:00
Tom Cosgrove
eee0d6ce6b Extend the unit tests for mbedtls_mpi_core_add_if() to also test mbedtls_mpi_core_add()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-10-25 16:29:58 +01:00
Minos Galanakis
a081c51cd3 Renamed mpi_core_get_mont_R2_unsafe_neg -> mpi_core_get_mont_r2_unsafe_neg
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-10-25 15:12:38 +01:00
Minos Galanakis
ae4fb671b4 mbedtls_mpi_core_get_mont_R2_unsafe: Removed NULL input checking
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-10-25 15:12:38 +01:00
Minos Galanakis
e1913a8da8 test_suite_bignum: Updated test cases for mbedtls_mpi_core_get_mont_R2_unsafe
This patch adds tests for 192 and 2048 bits inputs.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-10-25 15:12:31 +01:00
Minos Galanakis
b9243ef231 test_suite_bignum: Fixed whitespace issues
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-10-25 15:12:23 +01:00
Minos Galanakis
4f43f61c6a Renamed mbedtls_mpi_get_montgomery_constant_unsafe to mpi_core_get_mont_R2_unsafe
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-10-25 15:12:23 +01:00
Minos Galanakis
1a1b175554 test_suite_bignum: Added tests for mpi_get_montgomery_constant_unsafe()
This patch adds the test for the method calculating the RR. The input/expected
data are generated manually using the following Python3 snippet:

~~~~~
import math

title="mpi_get_montgomery_constant_unsafe"
tt = title + " #{}"

in_data = [ "0f", ... ]

def limb_no(number, bil=64):
    return int(math.ceil(int.bit_length(number)/(bil * 1.0)))

def calc_rr(number, bil=64 ):
    return '{:x}'.format(pow(pow(2, limb_no(number, bil) * bil), 2, number))

def calc_rr_str(number, prefix=""):
    rr64 = calc_rr(number)
    rr32 = calc_rr(number, bil=32)
    return '{}:"{:x}":"{}":"{}"'.format(prefix,number, rr32, rr64)

print("\n\n".join(["{}\n{}".format(tt.format(in_data.index(v)+1), calc_rr_str(int(v,base=16), title)) for v in in_data]))
~~~~~

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-10-25 15:12:01 +01:00
Gilles Peskine
383b0bbea0
Merge pull request #6461 from tom-cosgrove-arm/fix-mbedtls_mpi_mod_modulus_init-calls-in-tests
mbedtls_mpi_mod_modulus_init() must be called before any 'goto exit' in tests
2022-10-25 13:40:17 +02:00
Gilles Peskine
e5a715e8c0
Merge pull request #6449 from gilles-peskine-arm/bignum-core-shift_r
Bignum core: shift_r
2022-10-25 10:40:39 +02:00
Gilles Peskine
af8ea3f738
Merge pull request #6468 from gilles-peskine-arm/bignum-test-suite-names
Rename test_suite_bignum for consistency
2022-10-25 10:40:29 +02:00
Andrzej Kurek
2c7993c456 depends.py: add a config option to unset MBEDTLS_USE_PSA
This lets us perform any test without MBEDTLS_USE_PSA
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-24 15:56:10 -04:00
Ronald Cron
2012361ae6
Merge pull request #6448 from ronald-cron-arm/tls13-kex-build-options
TLS 1.3 Introduce and use key exchange mode config options
2022-10-24 15:21:37 +02:00
Przemek Stekiel
ab0451bc2c Fix build command in test_psa_crypto_config_reference_hash_use_psa
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-24 11:29:35 +02:00
Przemek Stekiel
c86dedfdc1 Fix code style
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-24 09:16:04 +02:00
Przemek Stekiel
58bbc23ca3 Use coverage analyze as default task
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-24 08:10:10 +02:00
Ronald Cron
454eb9172d ssl-opt.sh: Fix list of TLS 1.2 key exchanges with cert
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-22 14:42:04 +02:00
Ronald Cron
70ed41754d ssl-opt.sh: Simplify TLS 1.3 dependencies
Simplify TLS 1.3 dependencies taking into
account that
MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
implies that MBEDTLS_SSL_PROTO_TLS1_3 is
defined.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-22 14:42:04 +02:00
Ronald Cron
5de538c9dd ssl-opt.sh: Remove requires_key_exchange_with_cert_in_tls12_enabled
Remove requires_key_exchange_with_cert_in_tls12_enabled
and use `requires_any_configs_enabled` directly instead.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-22 14:42:04 +02:00
Ronald Cron
c3f43b663e all.sh: Add components testing TLS 1.3 kex partial enablement
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-22 14:42:04 +02:00
Ronald Cron
8328113cad ssl-opt.sh: Fix some test checks for ephemeral only kex build
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-22 14:42:04 +02:00
Ronald Cron
59625848e6 ssl-opt.sh: TLS 1.3 kex: Use MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_*ENABLED
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-22 14:42:04 +02:00
Ronald Cron
73fe8df922 Introduce and use MBEDTLS_SSL_HANDSHAKE_WITH_PSK_ENABLED
Introduce and use
MBEDTLS_SSL_HANDSHAKE_WITH_PSK_ENABLED to
guard TLS code (both 1.2 and 1.3) specific
to handshakes involving PSKs.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-22 14:42:04 +02:00
Ronald Cron
e68ab4f55e Introduce and use MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED
Introduce and use
MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED to
guard TLS code (both TLS 1.2 and 1.3) specific
to handshakes involving certificates.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-22 14:42:04 +02:00
Ronald Cron
41a443a68d tls13: Use MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK.*ENABLED
Use MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_PSK_ENABLED
instead of MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED to guard
code specific to one of the TLS 1.3 key exchange mode with
PSK.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-22 14:42:04 +02:00
Ronald Cron
928cbd34e7 tls13: Use MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
Use MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
instead of MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED to guard
code specific to the TLS 1.3 ephemeral key exchange mode.

Use it also for the dependencies of TLS 1.3 only tests
relying on ephemeral key exchange mode, but for
tests in tls13-kex-modes.sh where the change is done
later using all
MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_.*ENABLED macros.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-22 14:42:04 +02:00
Ronald Cron
d8d2ea5674 Add TLS 1.3 key exchange mode config options
Add TLS 1.3 specific configuration options
to enable/disable the support for TLS 1.3
key exchange modes.

These configurations are introduced to
move away from the aforementioned
enablement/disablement based on
MBEDTLS_KEY_EXCHANGE_xxx_ENABLED options
that relate to group of TLS 1.2
ciphersuites.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-22 14:41:57 +02:00
Andrzej Kurek
ba970be142 Fix test dependencies for cases that are PSA-based
These should be using PSA-type macros, not MBEDTLS_XXX_C.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-21 13:39:00 -04:00
Gilles Peskine
fc4f11b5d0 Improve test component name
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-21 19:34:54 +02:00
Gilles Peskine
a020d535ad Avoid having both test_suite_XXX.data and test_suite_XXX.*.data
Although our build scripts support that, it's annoying, because it makes
"test_suite_XXX" ambiguous between "all the data for
test_suite_XXX.function" and "just test_suite_XXX.data".

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-21 19:00:38 +02:00
Gilles Peskine
42832bd406 Don't use test_suite_mpi as an example
It just got renamed, and it's also not the most canonical example since it's
a somewhat deprecated interface. Make a different module the example.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-21 18:56:47 +02:00
Gilles Peskine
ce22066211 Rename test_suite_bignum for consistency with bignum.{h,c}
Align the name of the bignum test suite with the source module (which was
renamed from mpi.c to bignum.c in the PolarSSL 1.x days). This also brings
it into line with the test suites for the low-level bignum interfaces.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-21 18:54:43 +02:00
Andrzej Kurek
ed05279e4f Comment fix
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-21 10:28:55 -04:00
Andrzej Kurek
d066c79d7e Add missing ECB requirements for PSA cipher aes tests
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-21 10:28:55 -04:00
Andrzej Kurek
8f26c8a0cf Fix a typo in test_suite_cipher
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-21 10:28:55 -04:00
Ronald Cron
89ca977128 ssl-opt.sh: Improve dependencies of some TLS 1.3 test cases
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-21 14:47:00 +02:00
Ronald Cron
bc5adf4ef8 ssl-opt.sh: Add dependencies on handshake with cert
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-21 14:47:00 +02:00
Ronald Cron
2ea36af693 ssl-opt.sh: TLS 1.3 kex: Do not use sig_algs if no cert
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-21 14:47:00 +02:00
Ronald Cron
81cd7ab492 tests: ssl: Add missing dependency on MBEDTLS_X509_CRT_PARSE_C
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-21 14:47:00 +02:00
Ronald Cron
f64cc03b09 tests: ssl: Add missing dependencies on certificate based handshake
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-21 14:47:00 +02:00
Ronald Cron
457fb7a523 tests: ssl: Fix ciphersuite identifier
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2022-10-21 14:44:45 +02:00
Przemek Stekiel
4e95590ae7 analyze_outcomes.py: Add test coverage regresion analyze for driver only builds
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-21 13:43:13 +02:00
Przemek Stekiel
01df9ddda7 Add test component: component_test_psa_crypto_config_reference_hash_use_psa
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-21 13:43:13 +02:00
Manuel Pégourié-Gonnard
0e7e47147c
Merge pull request #6447 from mprse/driver-only-hash-gap
Fix test gap in driver-only-hashes build
2022-10-21 10:32:43 +02:00
Manuel Pégourié-Gonnard
45c6792faf
Merge pull request #6385 from AndrzejKurek/depends-py-reloaded
Unified tests/scripts/depends.py - reloaded
2022-10-21 10:17:58 +02:00
Tom Cosgrove
be17655b57 mbedtls_mpi_mod_modulus_init() must be called before any 'goto exit' in tests
Fixes Coverity issues 381527 and 381526.

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-10-20 16:57:10 +01:00
Janos Follath
560805d665 Fix mbedtls_mpi_core_add_if test aliasing
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-10-20 12:04:40 +01:00
Przemek Stekiel
2c95a56e13 Remove KNOWN_MBEDTLS_SUPPORTED_HASH_ALG as it is now not used anywhere
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-20 12:38:44 +02:00
Gilles Peskine
b0ee577287 Bignum core: test shift_r
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-20 12:00:57 +02:00
Janos Follath
ba516f7524 mpi_core_add_if test: Remove dependency on old API
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-10-20 10:59:50 +01:00
Janos Follath
e153a715f0 mpi_core_add_if: simplify tests
Use the new, limb size aware base class to generate tests for
mpi_core_add_if().

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-10-20 10:40:03 +01:00
David Horstmann
2bb9c8a884 Change brace initialization to memset
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-20 10:18:37 +01:00
David Horstmann
01dd548025 Minor fixes to x509_get_name() test function
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-19 17:13:57 +01:00
Werner Lewis
f1c24f0fbc Add missing include
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 16:43:22 +01:00
Werner Lewis
bd3ddafee2 Move tests added in #6289
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:36:18 +01:00
Werner Lewis
6baf12b18d Move legacy mod functions back to test_suite_mpi
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
ffe4478936 Move mpi_core_bitlen tests to bignum_core files
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
1b20e7e645 Redefine result() method to return List
Many bignum tests have multiple calculated result values, so return
these as a list, rather than formatting as a string.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
99e8178fa7 Add module for bignum_core test generation
Separate file is added for classes used to generate cases for tests
in bignum_core.function. Common elements of the BignumOperation class
are added to classes in a new common file, for use across files.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
0c6ea12145 Move bignum_mod tests into separate files
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
c9b6a0aef9 Move bignum_mod_raw tests into separate files
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
c6004a2ab3 Move bignum_core tests into separate files
Test cases for mpi_core_add_if, mpi_core_mla, mpi_core_sub,
mpi_core_montmul are not copied into new files, these are generated in
subsequent commits.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:19:53 +01:00
Gilles Peskine
149c1516e7
Merge pull request #6435 from mpg/improve-outcome-analysis
Improve outcome analysis for driver-only builds
2022-10-19 15:54:17 +02:00
Gilles Peskine
db2996357c
Merge pull request #6289 from gabor-mezei-arm/6237_Add_conditional_assign_and_swap_for_bignum
Bignum: Add safe conditional assign and swap for the new MPI types
2022-10-19 15:51:19 +02:00
Andrzej Kurek
b8a97e7520 depends.py: rename domains argument to tasks
Tasks can consist of domains and/or jobs.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
629c412e81 depends.py documentation fixes
Now that the format of exclusive groups has been changed,
update the documentation using it too.

Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
b489f958b8 depends.py: remove config options that are unset anyway
Over the lifespan of this script these options have been removed
from the "full" configuration.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
a44c5bcdb7 depends.py: rename config_pl usage to config_py
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
22b959d9a5 depends.py - add SHA256 dependency of LMS
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
65b2ac1f1d Change the way exclusive groups are defined in depends.py
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
f4b18672ff depends.py: fix TLS 1.3 requirements
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
a0cb4fa302 Improve depends.py readability
Switch from SHA224 & SHA384 testing to SHA256 and SHA512.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
b50754ae86 Switch from x509_CRT_PARSE to KEY_EXCHANGE_WITH_CERT_ENABLED
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
e5535e3123 Add MBEDTLS_DES_C exclusive group dependencies
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
a2a9688501 Fix the memory allocation in test_suite_ssl
ASSERT_ALLOC calculates the size itself, and the parameter indicates number of elements.
```
mbedtls_calloc( sizeof( *( pointer ) ),  ( length ) );  
```
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
6454a90c6d Remove pre-1_2 TLS dependencies from depends.py
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
658442fe78 Remove unnecessary ECP_C dependencies
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
e5a5cc1944 Remove the dependency of tls1_3 key evolution tests on curve25519
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
daf43fbe21 Move the location of MBEDTLS_ECP_C dependencies
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
2d637c4cbb Fix unchecked allocation in test_suite_ssl
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
01af84a0ca depends.py: Add script documentation
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
2f8ac287b6 Disable MBEDTLS_TEST_HOOKS in depends.py
This option was increasing testing duration
by about 40%.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
eabeb30c65 Fix SHA512 vs SHA384 dependencies
When building SHA512 without SHA384,
there are some code paths that resulted
in unused variables or usage of undefined code.
This commit fixes that.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
228b12ce54 Rework depends.py to run more tests with hashes
The test coverage reduction introduced in
dc25cee lowered the coverage of hash tests
due to intertwining dependencies.
This commit introduces a new class for building
a domain using both the complementary
and exclusive classes.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
fe46949686 depends.py: disable part of the test jobs
Disable exclusive jobs that run with a single
config disabled. A lot more bugs should be found by running jobs with only one config
of a family enabled.
This will also lessen the burden on the CI.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
fcbd2acbc2 Split depends.py all.sh job into seven
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
202932f521 Use upper case for constants in depends.py
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
3322c22087 Improve depends.py structrue
Apply most improvements suggested by pylint.
Use config.py instead of config.pl.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:09 -04:00
Andrzej Kurek
0e8b2d74f0 Fix python formatting and indentation
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Andrzej Kurek
3cca0c8e68 Add an all.sh component running depends.pl
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Andrzej Kurek
e05b17fb85 Update depends.py
Remove old and add new dependencies.
Introduce a way to handle non-trivial problems 
stemming from exclusive group testing.
Exclude SHA256 and SHA512, as these are tested
in SHA224 and SHA384 jobs, respectively.
Change config.h to mbedtls_config.h).
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Andrzej Kurek
e64bd43495 Add missing ECP and ECDH dependencies in ssl test suites
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Andrzej Kurek
8e44139ca0 Add missing CURVE25519 requirements to TLS 1.3 tests
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Andrzej Kurek
84f30f2eb0 Add missing SHA256 dependency
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Andrzej Kurek
e38b788b79 Add missing key exchange dependencies
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Andrzej Kurek
90e8204476 Add missing SHA256 and ECDSA_C dependencies in test_suite_ssl
Most of the tests (including those using endpoint_init functions) parse
certificates that require MBEDTLS_SHA256_C to be present.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Andrzej Kurek
0abebebe6d Refactor ssl test suite to use pointers more
This way it's easier to track structures that are partially set up.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Andrzej Kurek
f502bcb13e Fix missing AES dependencies
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Gilles Peskine
34a1557df6 Add domains for symmetric ciphers
Add a domain for cipher base algorithms (block permutations and stream
ciphers), a domain for block cipher chaining modes and a domain for
block cipher padding modes.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Gilles Peskine
c3b4deeb6c When exercising key exchanges, don't build the test suites
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Gilles Peskine
584c24ace4 Declare more reverse dependencies
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Gilles Peskine
b1284cf6bc Don't test builds with only deprecated hashes
Don't try to build with only SHA-1 or with only RIPEMD160 or with only
MD{2,4,5}.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Gilles Peskine
bf7537d0a9 Use the full config as the baseline for all jobs
Start each job from the full config minus some memory management
settings and the job-specific settings.

The original content of config.h no longer influences the
configurations used for the jobs (but it still influences what jobs
may run, in that the set of jobs is partly built by parsing #define
and //#define lines in config.h).
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Gilles Peskine
e85163bb5c Simplify final passed/failed reporting
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Gilles Peskine
0fa7cbeeb9 Add basic support for colored output
Show "pass" lines in green and "fail" lines in red.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Gilles Peskine
54aa5c6957 Factor running config.pl into its own function
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Gilles Peskine
46c8256547 Flush log output after each line
Otherwise the output can be out of order when redirected.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Gilles Peskine
b39e3ecee6 New script to exercise compilation options
Unify curves.pl, key-exchanges.pl, depends-pkalgs.pl and
depends-hashes.pl into a single, newly-written script.

For curves, key exchanges and hashes, in addition to testing
all-but-one settings in the group like the old scripts, also run the
tests with a single option in the group.

Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Andrzej Kurek
e40b92178d Fix missing padding dependencies
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Andrzej Kurek
252283f2aa Fix missing cipher mode dependencies
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-19 08:35:08 -04:00
Przemek Stekiel
8258ea7b7d test_suite_psa_crypto: adapt dependenies and guards so the test can run in the driver-only build
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-19 13:20:20 +02:00
Manuel Pégourié-Gonnard
0dc40773d6 Improve comments & messages
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-10-19 12:12:21 +02:00
Manuel Pégourié-Gonnard
deef905a1c Update is_builtin_calling_md() for PKCS#1 v2.1
Since https://github.com/Mbed-TLS/mbedtls/pull/6141 it can "fall back"
to PSA when MD is not available (but will use MD if available, to
preserve backwards compatibility).

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-10-19 11:02:15 +02:00
Manuel Pégourié-Gonnard
98b91d40d6 RSA PKCS#1 v1.5 no longer depends on MD
This has been the case since
https://github.com/Mbed-TLS/mbedtls/pull/6065 which forgot to update the
documentation, and also is_builtin_calling_md(), so update those.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-10-19 10:59:30 +02:00
Gabor Mezei
4dceede71b
Fix overly replacement in the documentation
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-10-18 16:44:17 +02:00
Przemek Stekiel
98b1af4e34 test_suite_debug: adapt dependenies so the test can run in the driver-only build
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-18 14:52:41 +02:00
Janos Follath
7cd1ebe0bb
Merge pull request #6296 from gilles-peskine-arm/test_data_generation-pr_6093_followup
Minor fixes to test_data_generation.py
2022-10-18 13:38:28 +01:00
Manuel Pégourié-Gonnard
d92fb01419 Skip bits not needed in outcome-analysis.sh
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-10-18 12:10:45 +02:00
David Horstmann
3cd67584bc Improve X509 DN test naming
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-17 17:59:10 +01:00
David Horstmann
d0e3d45e96 Add explanatory comments to raw DER test data
Break down the DER-encoded ASN.1 test data into its structure in a
comment and explain it, to make it easier to understand where the data
came from and how it is corrupted.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-17 17:55:04 +01:00
Gilles Peskine
47da7bfac8
Merge pull request #6434 from gilles-peskine-arm/lmots_import_export_test-memory_leak
LMS: Fix memory leak if unit test fails
2022-10-17 17:57:59 +02:00
Aditya Deshpande
cfb441d5ee Fix spacing and formatting
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-10-17 15:17:30 +01:00
Gabor Mezei
0c74e084d5
Fix condition
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-10-17 16:09:58 +02:00
Gilles Peskine
503d09b52d Fix memory leak if unit test fails
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-17 12:27:43 +02:00
Manuel Pégourié-Gonnard
6c6f04b651
Merge pull request #6419 from mpg/fix-assert-alloc-usage
Fix usage of ASSERT_ALLOC()
2022-10-17 12:10:48 +02:00
Gilles Peskine
8874cd570e
Merge pull request #4826 from RcColes/development
Add LMS implementation
2022-10-14 18:33:01 +02:00
Aditya Deshpande
40c05cc8e4 Newlines at end of file + trim trailing whitespace
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-10-14 16:46:51 +01:00
Aditya Deshpande
17845b8f71 Add driver wrapper function for raw key agreement, along with test call for transparent drivers.
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
2022-10-14 16:46:00 +01:00
Gabor Mezei
ffb4aa0ddc
Rename variables to have unambiguous names
Use bytes instead of len in the variable names.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-10-14 16:39:04 +02:00
Gabor Mezei
8bcd7cca94
Use count instead of bytes in ASSERT_ALLOC argument
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-10-14 16:18:10 +02:00
Tom Cosgrove
edca207260 MBEDTLS_CIPHER_CHACHA20_POLY1305 is an mbedtls_cipher_type_t not an mbedtls_cipher_mode_t
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-10-14 12:10:40 +01:00
Manuel Pégourié-Gonnard
b3c30907d6
Merge pull request #6383 from mprse/aead_driver_test
Enable testing of AEAD drivers with libtestdriver1
2022-10-14 11:11:01 +02:00
Manuel Pégourié-Gonnard
47b8de834d Fix usage of ASSERT_ALLOC()
The second argument is the number of elements of the type the first
argument is pointing to, so we shouldn't be using sizeof there.

This was resulting in overly large allocations.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-10-14 09:35:55 +02:00
Gilles Peskine
fa65237fd4 Fix which config header MBEDTLS_LMS_xxx is unset from
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-13 22:05:38 +02:00
Gilles Peskine
31c2dcb611 Fix file names in reproduction instructions in test data
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-13 20:48:15 +02:00
Gilles Peskine
2875aa7b01 Fix instructions and test data for pyhsslms interop tests
The test data was invalid because it had the extra 4-byte prefix for HSS.
Regenerate it (which produces completely new signatures since it is
randomized).

Rearrange the reproduction instructions for the second test case so that it
shows more clearly how to generate a second signature with the same private
key.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-13 20:45:05 +02:00
Raef Coles
8bccc999d9
Don't mention error type in LMS test comments
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 17:57:31 +01:00
Raef Coles
6d7d94a821
Use correct export length in LMS export tests
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 17:55:46 +01:00
Raef Coles
aa9d52bcdc
Rename LMS private key files to match library name
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 17:53:40 +01:00
Raef Coles
f8bfe2783b
Remove bad character from LMS test case
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 17:35:28 +01:00
Raef Coles
d543697092
Fix minor type in LMS test description
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 17:06:42 +01:00
Raef Coles
a2514f622f
Update pyhsslms test instructions with script
Due to tool name conflict hampering data reproduction

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 17:04:21 +01:00
Raef Coles
ce18e528ff Rename LMS private key files
And remove now-unnecessary modification to check_files.py

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 16:45:05 +01:00
Raef Coles
e4d96b804c Update LMS and LMOTS test comments
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 16:45:05 +01:00
Raef Coles
493724e3c2
Check correct output size in LMOTS export test
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 15:43:07 +01:00
Raef Coles
ed0e4591dc
Add output length test for LMS export too-big test
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 15:05:47 +01:00
Ronald Cron
49e4184812
Merge pull request #6299 from xkqian/tls13_add_servername_check
Add server name check when proposing pre-share key
2022-10-13 16:00:59 +02:00
Raef Coles
33f7d66304
Add output check to export too-big buffer tests
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:36 +01:00
Raef Coles
1d88ea870f
Remove unneeded NULL pointer checks in LMS tests
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:35 +01:00
Raef Coles
d1c1f7f7be
Disable LMS in all.sh tests that lack _WANT_SHA256
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:31 +01:00
Raef Coles
a21671123a
Remove sudo pip3 in LM(OT)S tests instructions
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:27 +01:00
Raef Coles
1b43a7448d
Clean up LMS and LMOTS feature dependencies
Remove SHA256 dependencies from tests, fix incorrect boolean logic in
check_config, and change depends_hashes.pl to disable LMS in one test

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:26 +01:00
Raef Coles
6b2c573b3d
And export buffer too large test to LMS and LMOTS
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:24 +01:00
Raef Coles
534f66f3f0
Fix assert arguments in LMS and LMOTS export tests
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:23 +01:00
Raef Coles
d1c2a80319
Remove duplicated assert from LMOTS tests
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:21 +01:00
Raef Coles
20d2e06ca4
Add cleanup frees in LMS and LMOTS tests
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:20 +01:00
Raef Coles
781f7bedb0
Properly mark LMOTS leak test as failed
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:18 +01:00
Raef Coles
d137c86125
Don't skip LMS tests due to out of memory error
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:17 +01:00
Raef Coles
76563399fd
Fix LMS and LMOTS test dependencies
Mark them as depending on PSA_WANT_ALG_SHA256 so that
test_depends_hashes_psa doesn't fail

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:15 +01:00
Raef Coles
59eb0d0f2b
Fix LMOTS signature leak test dependencies
As it requires MBEDTLS_LMS_PRIVATE

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:12 +01:00
Raef Coles
d0c701237a
Replace TEST_ASSERT with TEST_EQUAL in LMS tests
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:09 +01:00
Raef Coles
f9b8502865
Add LMS import/export negative tests
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:06 +01:00
Raef Coles
4511055511
Exclude binary LMS keys from file checking
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:05 +01:00
Raef Coles
9fc303a99a
Add extra LMOTS import negative tests
And fix failures that are related to the new tests

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:01 +01:00
Raef Coles
71f554b48f
Use real data for negative LMOTS tests
To avoid errors caused by the null public keys and signatures

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:30:00 +01:00
Raef Coles
66edf6a833
Use hsslms data for LMOTS import/export test
Also, test that export fails when the buffer is too small.

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:58 +01:00
Raef Coles
8b55ba623e
Source LMOTS data from hsslms
So it can be reproduced

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:57 +01:00
Raef Coles
a6b47c0aac
Add LMS hsslms interop tests
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:55 +01:00
Raef Coles
d6adcb6146
Add negative LMS import/export tests
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:53 +01:00
Raef Coles
810612e14e
Update LMS and LMOTS to use TEST_EQUAL
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:51 +01:00
Raef Coles
90e13fc3c6
Add repro instructions for LMS test data
Add more interop tests, and use real data for the negative tests

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:49 +01:00
Raef Coles
0dc604ed2b
Change how LMS and LMOTS negative tests work
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:48 +01:00
Raef Coles
7726678b23
Remove debugging code left in LMOTS tests
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:46 +01:00
Raef Coles
370cc43630
Make LMS public key export part of public key api
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:28 +01:00
Raef Coles
be3bdd8240
Rename LMS and LMOTS init/free functions
To match convention

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:18 +01:00
Raef Coles
5127e859d7
Update LMS and LMOTS dependency macros
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:11 +01:00
Raef Coles
b4568c5423
Disable LMS in PSA crypto client test
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:07 +01:00
Raef Coles
47bccb7e47
Disable LMS_PRIVATE in all.sh when LMS is disabled
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:06 +01:00
Raef Coles
a7e03adef5
Disable LMS in all.sh when PSA isn't enabled
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:04 +01:00
Raef Coles
98c504373c
Update LMS test description
To correct copy-paste error

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:29:02 +01:00
Raef Coles
40158e11fc
Add LMOTS test hook to header
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:58 +01:00
Raef Coles
9c9027b1a4
Add extra LMS and LMOTS tests
NULL-message and LMOTS signature leak tests

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:50 +01:00
Raef Coles
f5919e2997
Update LMS/LMOTS tests
Document tests and source of data, use test RNG, pass more parameters
into each test

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:43 +01:00
Raef Coles
e9479a0264
Update LMS API to support multiple parameter sets
Parameterise macros to allow variation of sizes

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:36 +01:00
Raef Coles
ab4f87413a
Add MBEDTLS_LMS_PRIVATE define
To enable private key operations

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:35 +01:00
Raef Coles
01c71a17b3
Update LMS and LMOTS api
Fix function names and parameters. Move macros to be more private.
Update implementation.

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:25 +01:00
Raef Coles
c8f9604d7b
Use PSA hashing for LMS and LMOTS
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:23 +01:00
Raef Coles
7dce69a27a
Make LMOTS a private api
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:22 +01:00
Raef Coles
8ff6df538c
Add LMS implementation
Also an LM-OTS implementation as one is required for LMS.

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:15 +01:00
Manuel Pégourié-Gonnard
f155ab9a91 Abort on errors when we should
We're not strictly required to abort, but at least to leave the context
is an invalid state. For "late" functions like input() and output(),
calling abort() is the easiest way to do that. Do it systematically for
input() and output() by using a wrapper. psa_pake_get_implicit_key() was
already doing it. For "early" function, we can just leave the operation
in its current state which is already invalid.

Restore previous tests about that. Not adding systematic tests, though,
just test the two functions that are the most important, and more likely
to return errors.

Since we now abort in more cases, we need to make sure we don't
invalidate the operation that's going to be re-used later in the test.
For that reason, use a copy of the operation for calls to input() and
output() that are expected to return errors.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-10-13 13:20:31 +02:00
Manuel Pégourié-Gonnard
b63a9ef09f Fix buffer sizes in ecjpake_setup test function
Also, the error code changed from INSUFFICIENT_MEMORY to INVALID_DATA.

Temporarily remove a test about aborting the operation on error.
Auto-abort will be re-introduced in the next commit in a more systematic
way.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-10-13 13:17:20 +02:00
Gilles Peskine
0fe6631486
Merge pull request #6291 from gilles-peskine-arm/platform.h-unconditional-3.2
Include platform.h unconditionally
2022-10-13 10:19:22 +02:00
Przemek Stekiel
072fad12d9 Disable MBEDTLS_SSL_TICKET_C in aead driver test.
MBEDTLS_SSL_TICKET_C depends now on: MBEDTLS_GCM_C || MBEDTLS_CCM_C || MBEDTLS_CHACHAPOLY_C.
All features are disabled in this config.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-13 09:59:52 +02:00
Manuel Pégourié-Gonnard
2aa5af9bec
Merge pull request #6403 from mpg/print-failed-suites
Print the list of failed suites in verbose mode
2022-10-13 09:59:45 +02:00
Xiaokang Qian
ed0620cb13 Refine code base on comments
Move code to proper macro guards protection
Fix typo issues

Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-10-12 11:06:51 +00:00
Xiaokang Qian
2f9efd3038 Address comments base on review
Change function name to ssl_session_set_hostname()
Remove hostname_len
Change hostname to c_string
Update test cases to multi session tickets

Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-10-12 11:06:49 +00:00
Xiaokang Qian
adf84a4a8c Remove public api mbedtls_ssl_reset_hostname()
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-10-12 11:05:11 +00:00
Xiaokang Qian
281fd1bdd8 Add server name check when proposeing pre-share key
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2022-10-12 11:03:41 +00:00
Gilles Peskine
8fd3254cfc
Merge pull request #6374 from mprse/enc_types
Test TLS 1.2 builds with each encryption type
2022-10-12 12:45:50 +02:00
Ronald Cron
78317c832b
Merge pull request #6327 from yuhaoth/pr/tls13-psk-after-session-tickets
TLS 1.3: PSK and NewSessionTicket: Add support for sending PSK and Ticket together.
2022-10-12 12:39:51 +02:00
Przemek Stekiel
ee1bb4145f Make sure that disabled features are not included in image and fix test config
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-12 10:15:59 +02:00
Gilles Peskine
fcee740b83 Automatically enable PK_PARSE for RSA in PSA
PSA crypto currently needs MBEDTLS_PK_PARSE_C to parse RSA keys to do almost
anything with them (import, get attributes, export public from private, any
cryptographic operations). Force it on, for symmetry with what we're doing
for MBEDTLS_PK_WRITE_C. Fixes #6409.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-11 21:15:24 +02:00
Gilles Peskine
aef1ba679d Add build with a typical configuration for a PSA crypto service
Disable non-crypto features that can't be called through the PSA API, as
well as algorithms that have no PSA interface.

This serves as a non-regression test for #6408 and #6409.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-11 21:09:21 +02:00
Gilles Peskine
58e5d804ee test_suite_pk: Add missing dependencies on MBEDTLS_PEM_PARSE_C
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-11 20:57:38 +02:00
Gilles Peskine
d23d8dee24 test_suite_dhm: Add missing dependencies on MBEDTLS_PEM_PARSE_C
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-11 20:57:21 +02:00
Gilles Peskine
9624a5932e Add mbedtls_dhm_parse_dhmfile test case with DER input
dh.optlen.der is the result of converting dh.optlen.pem from PEM to DER.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-11 20:52:34 +02:00
Jerry Yu
c2bfaf00d9 fix wrong typo
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-10-11 18:07:19 +08:00
Manuel Pégourié-Gonnard
ac6c67053d Print the list of failed suites in verbose mode
In verbose mode, the full output of each failing suite is printed out,
which for some suites runs in the 1000s of lines. If you didn't redirect
output to a file, this is a lot to scroll and can make it hard to
quickly identify which test suites failed.

So, let's print out that information at the end. This is useful
information for starting to figure out what went wrong.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-10-11 10:48:32 +02:00
Gilles Peskine
b50e433b66 Test mbedtls_mpi_core_bitlen
Copy the test data for mbedtls_mpi_bitlen except for 0-length and negative cases.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-10 23:03:47 +02:00
Gilles Peskine
e943283f2f More mbedtls_mpi_bitlen test cases
* with leading zero limb
* with trailing zero limb
* negative

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-10 23:03:47 +02:00
Gilles Peskine
24baa81043 Improve mbedtls_mpi_bitlen test descriptions
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-10 23:03:47 +02:00
Gilles Peskine
c5772a194e mbedtls_test_read_mpi_core: allow odd number of hex digits
Test functions must now take a char* argument rather than data_t*. This does
not affect existing test data.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-10 23:03:47 +02:00
Janos Follath
1b5c85c75b
Merge pull request #6386 from gilles-peskine-arm/bignum-mbedtls_test_read_mpi_core
Introduce mbedtls_test_read_mpi_core
2022-10-10 15:14:46 +01:00
Jerry Yu
03aa174d7c Improve test message and title
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-10-10 21:48:37 +08:00
Gabor Mezei
44ba2f6db9
Add more test cases
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-10-10 15:32:12 +02:00
Gabor Mezei
a67a1a3ebc
Remove the 'is_fail' parameter from the test functions
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-10-10 15:25:59 +02:00
Gabor Mezei
d71eb0c3ac
Use better test macro
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-10-10 13:09:04 +02:00
Gabor Mezei
d6441da4c5
Remove redundant memory initialization
When memory is allocated it is also initialized with 0.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-10-10 13:05:16 +02:00
Gabor Mezei
251cb632f1
Remove unused macro definition
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-10-10 13:02:21 +02:00
Przemek Stekiel
52a428b824 Fix MBEDTLS_SSL_TICKET_C, MBEDTLS_SSL_SESSION_TICKETS dependencies
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-10 11:23:18 +02:00
Przemek Stekiel
42bb3ff40b Adapt expected results in ChaCha20-Poly1305 ( invalid tag length)
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-10 07:28:40 +02:00
Jerry Yu
63b06ea06e Update test cases
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-10-08 14:56:38 +08:00
Jerry Yu
25ab654781 Add dummy ticket support
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-10-07 10:11:05 +08:00
Jerry Yu
8897c07075 Add server only guards for psk callback
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-10-07 10:11:05 +08:00
Przemek Stekiel
c1ceae4848 crypto_config_test_driver_extension.h: add support for ChaCha20 - Poly1305
This is done to have LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305 defined in libtestdriver1.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-06 16:53:47 +02:00
David Horstmann
db73d3b149 Add mbedtls_x509_get_name memory leak unit test
Introduce a unit test to test mbedtls_x509_get_name() and add a testcase
with a corrupt DER-encoded name that causes mbedtls_x509_get_name() to
have to cleanup things it is allocated. If it fails to do this, a memory
leak is detected under Asan builds.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-05 13:09:57 +01:00
Manuel Pégourié-Gonnard
ec7012dbc7 Fix I/O format of PSA EC J-PAKE for compliance
The format used by the mbedtls_ecjpake_xxx() APIs and that defined by
the PSA Crypto PAKE extension are quite different; the former is
tailored to the needs of TLS while the later is quite generic and plain.
Previously we only addressed some part of this impedance mismatch: the
different number of I/O rounds, but failed to address the part where the
legacy API adds some extras (length bytes, ECParameters) that shouldn't
be present in the PSA Crypto version. See comments in the code.

Add some length testing as well; would have caught the issue.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-10-05 12:52:48 +02:00
Gilles Peskine
99a82dce74 Readability improvement
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-05 11:20:56 +02:00
Gilles Peskine
80ca44f33c
Merge pull request #6325 from gabor-mezei-arm/6308_missing_initialization_in_test
Add initialization for structures in test
2022-10-05 11:09:35 +02:00
Gilles Peskine
22514eb99b Fix typo in documentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-04 15:09:53 +02:00
Gabor Mezei
8fcde5bb8e
Remove duplicate test case
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-10-04 13:53:33 +02:00
Gabor Mezei
02e5d439db
Add more tests for cond_assign/swap functions
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-10-03 16:45:11 +02:00
Gabor Mezei
6546a6cc03
Rewrite tests for cond_assign/swap
The cond_swap and cond_assign test functions now requires the same limb size
for the MPI parameters.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-10-03 14:56:51 +02:00
Glenn Strauss
2ff77119df mbedtls_ecp_point_read_binary from compressed fmt
mbedtls_ecp_point_read_binary from MBEDTLS_ECP_PF_COMPRESSED format

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
2022-10-03 05:43:27 -04:00
Przemek Stekiel
6a5cc74cc4 Fix typos and comments
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-03 09:04:16 +02:00
Przemek Stekiel
bd99a0221b test_driver_aead.c: add support for LIBTESTDRIVER1 tests
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-02 21:01:23 +02:00
Przemek Stekiel
e290f2ea14 all.sh: add testing of AEAD drivers with libtestdriver1
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-02 20:58:39 +02:00
Gilles Peskine
5bbdfce44c Streamline mbedtls_mpi_core_lt_ct unit test
Use mbedtls_test_read_mpi_core() to read the test data. Among other
benefits, X and Y are now allocated to their exact size, so analyzers (Asan,
Valgrind, Coverity, ...) have a chance of complaining if the tested function
overflows the buffer.

Remove TEST_CF_PUBLIC calls which are no longer necessary.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-30 18:53:04 +02:00
Gilles Peskine
3aae4e815e New function mbedtls_test_read_mpi_core
Allocate and read an MPI from a binary test argument.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-30 18:51:41 +02:00
Gilles Peskine
571576fc5c Move the definition of data_t to a header file
This way it can be used in helper functions.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-30 18:51:41 +02:00
Gilles Peskine
bdc7b8bb6a Allow test assertions on constant-flow scalar data
When testing a function that is supposed to be constant-flow, we declare the
inputs as constant-flow secrets with TEST_CF_SECRET. The result of such a
function is itself a constant-flow secret, so it can't be tested with
comparison operators.

In TEST_EQUAL, TEST_LE_U and TEST_LE_S, declare the values to be compared as
public. This way, test code doesn't need to explicitly declare results as
public if they're only used by one of these macros.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-30 18:51:41 +02:00
Gilles Peskine
97483b0fd4 Remove incorrect comment
This comment (which used to be attached to the implementation, and should
not have been moved to the header file) is incorrect: the library function
mbedtls_mpi_read_string preserves leading zeros as desired, but does not
create a zero-limb object for an empty string.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-30 18:51:41 +02:00