1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-05-28 16:21:27 +03:00

17370 Commits

Author SHA1 Message Date
Gilles Peskine
581c460161 Fix negative zero created by (-A) + (+A) or (-A) - (-A)
In mbedtls_mpi_add_mpi() and mbedtls_mpi_sub_mpi(), and by extention
mbedtls_mpi_add_int() and mbedtls_mpi_sub_int(), when the resulting value
was zero, the sign bit of the result was incorrectly set to -1 when the
left-hand operand was negative. This is not a valid mbedtls_mpi
representation. Fix this: always set the sign to +1 when the result is 0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-10 15:15:25 +01:00
Gilles Peskine
ee78b6e642 For binary operations, test both x op y and y op x
This exposes a bug in mbedtls_mpi_add_mpi() and mbedtls_mpi_sub_mpi() which
will be fixed in a subsequent commit.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-10 15:15:25 +01:00
Gilles Peskine
cae0c745fc Document invariants of MPI objects
Note that s must be +1 for zero.

Note that p may be NULL for zero, when n is 0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-10 15:15:25 +01:00
Gilles Peskine
4e47bdc2fa Unify mbedtls_mpi_add_mpi and mbedtls_mpi_sub_mpi
mbedtls_mpi_add_mpi() and mbedtls_mpi_sub_mpi() have the same logic, just
with one bit to flip in the sign calculation. Move the shared logic to a new
auxiliary function. This slightly reduces the code size (if the compiler
doesn't inline) and reduces the maintenance burden.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-10 15:15:25 +01:00
Gilles Peskine
676df8ec88
Merge pull request #6578 from gilles-peskine-arm/bignum-test-suite-names-2.28
Backport 2.28: Rename test_suite_bignum for consistency
2022-11-10 14:40:16 +01:00
Gilles Peskine
6b5fca12f4
Merge pull request #6580 from yanrayw/mbedtls-2.28
Backport 2.28: Add build version to the output of ssl_client2 and ssl_server2
2022-11-10 14:39:35 +01:00
Gilles Peskine
d7d5e9a328
Merge pull request #6536 from davidhorstmann-arm/2.28-change-test-templating-syntax
[Backport 2.28] Change test templating syntax to be valid C
2022-11-10 12:05:58 +01:00
Yanray Wang
d818c0856c Fix: include version.h in ssl_test_lib.h
In development, mbedtls/version.h is getting included indirectly
in via mbedtls/build_info.h, but this doesn't happen in 2.28.
This commit add this dependency in ssl_test_lib.h

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2022-11-10 16:31:02 +08:00
Yanray Wang
4d4b077751 Add output of build version in ssl_server2 and ssl_client2
Backport the changes in PR 6436 to mbedtls-2.28.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2022-11-10 14:37:49 +08:00
Gilles Peskine
d5c76cfd9f 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-11-09 21:00:28 +01:00
Gilles Peskine
618f989954 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 in the development branch. Make a different
module the example.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-11-09 21:00:28 +01:00
Gilles Peskine
5b68608b40 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-11-09 21:00:28 +01:00
Gilles Peskine
2478b3499f
Merge pull request #6572 from mpg/improve-test-suites-listing-2.28
[backport 2.28] Improve test suite detection in run-test-suites.pl
2022-11-09 19:03:24 +01:00
David Horstmann
8eff06f1d6 Minor improvements to test code script
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-09 17:31:08 +00:00
David Horstmann
da2fe26db7 Fix incorrect condition in is_compression_bad()
The transport is allowed to be MBEDTLS_SSL_TRANSPORT_DATAGRAM when the
compression is MBEDTLS_SSL_COMPRESS_NULL.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-09 15:08:36 +00:00
aditya-deshpande-arm
1d00c3dea6 Add comments after #endif
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-09 15:08:36 +00:00
Manuel Pégourié-Gonnard
78dea63de9 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-09 12:06:43 +01:00
Gilles Peskine
b6e93b6441
Merge pull request #6560 from gilles-peskine-arm/bignum-aliasing-6552-2.28
Backport 2.28: Add comments for some forbidden aliasing in bignum.h interfaces
2022-11-08 17:15:33 +01:00
Gilles Peskine
760d1ffef9
Merge pull request #6554 from daverodgman/development-2.28
Backport 2.28: Fix outdated reference in debug message
2022-11-08 17:12:27 +01:00
Gilles Peskine
cb492102bf
Merge pull request #6380 from Kabbah/backport2.28-x509-info-hwmodulename-hex
[Backport 2.28] `x509_info_subject_alt_name`: Render HardwareModuleName as hex
2022-11-08 17:11:09 +01:00
Glenn Strauss
1dccfdb904 Add comments for some forbidden aliasing in bignum
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
2022-11-08 13:55:53 +01:00
Jan Bruckner
a084c93be9 Fix outdated reference in debug message
Signed-off-by: Jan Bruckner <jan@janbruckner.de>
2022-11-08 10:55:44 +00:00
Janos Follath
9e4ea3a8a8 Add ChangeLog entry
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-08 09:09:14 +00:00
Janos Follath
95655a2ba0 mpi_exp_mod: protect out of window zeroes
Out of window zeroes were doing squaring on the output variable
directly. This leaks the position of windows and the out of window
zeroes.

Loading the output variable from the table in constant time removes this
leakage.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-08 09:09:14 +00:00
Janos Follath
91c0286917 mpi_exp_mod: load the output variable to the table
This is done in preparation for constant time loading that will be added
in a later commit.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-08 09:09:14 +00:00
David Horstmann
b410566ba7 Reverse logic for compression in ssl_cli.c
Change is_compression_ok() to is_compression_bad() for more semantics
that are a better match for what's really going on in the case of no
compression support.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-07 16:33:57 +00:00
David Horstmann
08a37516ff Minor style fixes to ssl_cli.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-07 15:55:00 +00:00
David Horstmann
bcc18f2bec Simplify PSA fallback logic in ssl_ticket.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-07 14:48:38 +00:00
David Horstmann
9fc2f959b3 Change 0-checks to NULL-checks in ecp.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-07 14:48:38 +00:00
David Horstmann
0955f82642 Tidy up compression logic with auxiliary function
This refactors some logic in ssl_cli.c, removing some previously added
technical debt.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-07 14:48:29 +00:00
David Horstmann
0448de58d7 Simplify logic in ssl_cli.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-07 14:08:12 +00:00
David Horstmann
dbb6f08c3f Eliminate bad_params variable
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-07 14:08:12 +00:00
David Horstmann
79bb19f702 Remove redundant checks for renegotiation
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-11-07 14:08:12 +00:00
David Horstmann
14bae83ca0 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-07 09:55:35 +00:00
Gilles Peskine
c4698502d6
Merge pull request #6491 from davidhorstmann-arm/2.28-fix-unusual-macros-0
[Backport-ish 2.28] Fix unusual macros
2022-11-03 10:29:06 +01:00
Dave Rodgman
e9e0eeccec
Merge pull request #6525 from daverodgman/fix-duplicate-header-2.28
Remove duplicate function prototype - 2.28 backport
2022-11-02 13:06:04 +00:00
Dave Rodgman
e43caca4ab
Merge pull request #6527 from daverodgman/update_pr_template-2.28
Update pr template - 2.28 backport
2022-11-02 13:05:03 +00:00
Dave Rodgman
a4f10bec28
Merge pull request #6526 from daverodgman/psalinks-2.28
Update PSA links in README.md - 2.28 backport
2022-11-02 10:02:03 +00:00
Dave Rodgman
490f804555 Improve documentation for psa_crypto_cipher.h
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-02 09:29:35 +00:00
Dave Rodgman
8e322b1e99 Move declaration of mbedtls_cipher_info_from_psa into psa_crypto_cipher.h
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-02 09:27:01 +00:00
Dave Rodgman
d39cf1e07c Align CONTRIBUTING.md with development
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-01 20:58:30 +00:00
Dave Rodgman
bc1e670fb7 Improve list formatting
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-01 20:56:49 +00:00
Dave Rodgman
9a1c38a3c1 Reinstate note about all PRs receiving review
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-01 20:56:45 +00:00
Dave Rodgman
53b65f65ff Update CONTRIBUTING.md, and refer to this from the template
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-01 20:55:32 +00:00
Dave Rodgman
f1d74acb18 Update PR template
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-01 20:55:20 +00:00
Dave Rodgman
35e2b2b2bd
Merge pull request #6523 from daverodgman/fix_ssl_zeroize-2.28
Fix zeroization at NULL pointer - 2.28 backport
2022-11-01 20:50:33 +00:00
Dave Rodgman
428ef795e6 Update PSA links in README.md
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-01 20:43:24 +00:00
Dave Rodgman
e222637cfe Remove duplicate function prototype
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-01 16:41:48 +00:00
Dave Rodgman
febe14e6e0 Add Changelog
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-01 16:28:20 +00:00
Dave Rodgman
369f495afc Fix zeroization at NULL pointer
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-11-01 16:11:47 +00:00