16779 Commits

Author SHA1 Message Date
Paul Elliott
06986de4ea
Merge pull request #6066 from AndrzejKurek/fix-some-resource-leaks-2-28
Fix `mbedtls_pk_parse_public_key` resource leaks
2022-07-05 23:12:11 +01:00
Andrzej Kurek
cd5e671b5a Add a changelog entry for pkparse bugs
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-07-05 10:32:38 -04:00
Paul Elliott
b39b499932 Add pem_free() to other error paths in pk_parse_public_key()
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2022-07-05 10:27:34 -04:00
Leonid Rozenboim
763ee3c6b4 Fix resource leaks
These potential leaks were flagged by the Coverity static analyzer.

Signed-off-by: Leonid Rozenboim <leonid.rozenboim@oracle.com>
2022-07-05 06:07:43 -04:00
Manuel Pégourié-Gonnard
e3954e36d9
Merge pull request #5997 from gilles-peskine-arm/storage-format-doc-202206-2.28
Backport 2.28: Documentation about storage format compatibility
2022-07-01 12:21:21 +02:00
Manuel Pégourié-Gonnard
2e4b5b2c43
Merge pull request #5996 from gilles-peskine-arm/storage-format-doc-2.25-2.28
Backport 2.28: Update storage format specification for Mbed TLS 2.25.0+
2022-07-01 09:25:42 +02:00
Ronald Cron
0ae1c1c49c
Merge pull request #5991 from gilles-peskine-arm/asn1write-0-fix-2.28
Backport 2.28: Improve ASN.1 write tests
2022-06-30 15:42:31 +02:00
Gilles Peskine
be059e4b07 For status values, the macro expansions must not change either
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:57:27 +02:00
Gilles Peskine
fe84f38e26 More wording improvements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:57:27 +02:00
Gilles Peskine
a6e71bf864 Spelling
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:57:27 +02:00
Gilles Peskine
3d96ea1e4c Add warnings to test code and data about storage format stability
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:57:27 +02:00
Gilles Peskine
f4be01fadb Document how to interpret negative reports
The abi_check script has common false positives. Document the intent of each
family of checks and typical cases of false positives that can be overridden.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:57:27 +02:00
Gilles Peskine
4b9f7a28c9 Remove redundant sentence
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:57:27 +02:00
Gilles Peskine
6140d2efcc Backward compatibility: the key store
Promise that we will keep supporting existing key store formats, at least
until a major version comes along.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:57:27 +02:00
Gilles Peskine
6bfc19a648 Backward compatibility: add a note about the configuration
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:57:27 +02:00
Gilles Peskine
43bd07da06 Add compatibility notes regarding values embedded in the key store
Certain numerical values are written to the key store. Changing those
numerical values would break the backward compatibility of stored keys. Add
a note to the affected types. Add comments near the definitions of affected
values.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:51:01 +02:00
Gilles Peskine
7ccc5e6d4e Document how PSA identifiers are generally constructed
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:51:01 +02:00
Gilles Peskine
fcc3a68311 Historical update: the layout on stdio changed in Mbed Crypto 1.1.0
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:48:34 +02:00
Gilles Peskine
4985728d4c Typos
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:48:34 +02:00
Gilles Peskine
c64eab3784 Repeat the seed file documentation in 2.25.0
This way the 2.25.0 section is now fully self-contained.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:48:34 +02:00
Gilles Peskine
5d20c735a0 Fix wrong type in C snippet
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:48:34 +02:00
Gilles Peskine
141a770b68 Add section for Mbed TLS 2.25.0+
We hadn't updated the storage specification in a while. There have been no
changes to the storage layout, but the details of the contents of some
fields have changed.

Since this is now a de facto stable format (unchanged between 2.25 and 3.2),
describe it fully, avoiding references to previous versions.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-30 13:48:34 +02:00
Dave Rodgman
eee5c8ac23
Merge pull request #5982 from gilles-peskine-arm/selftest-calloc-pointer-comparison-fix-2.28
Backport 2.28: Remove largely useless bit of test log to silence GCC 12
2022-06-29 15:25:00 +01:00
Gilles Peskine
d97de551e4 Don't call memcpy(NULL, 0) which has undefined behavior
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-29 11:04:48 +02:00
Gilles Peskine
96b8d31ef6 ASN.1: test that we can parse what we can write
In asn1_write tests, when there's a parsing function corresponding to the
write function, call it and check that it can parse what we wrote.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-29 11:04:48 +02:00
Gilles Peskine
53875878b8 Fix copypasta in test data
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-29 11:04:48 +02:00
Gilles Peskine
53785928fa ASN.1 write tests: test with larger buffer
Test with the output buffer size up to *and including* the expected output
size plus one. `... < expected->len + 1` was evidently a mistake.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-29 11:04:48 +02:00
Gilles Peskine
bb34feea0d Fix bug whereby 0 was written as 0200 rather than 020100
0200 is not just non-DER, it's completely invalid, since there has to be a
sign bit.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-29 11:04:48 +02:00
Gilles Peskine
62f217b180 Add MPI write tests when the MPI object has a leading zero limb
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-29 11:04:48 +02:00
Gilles Peskine
4269185aa1 Fix mismatch between test data and test description
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-29 11:04:48 +02:00
Gilles Peskine
7f56783a0a Uncomment mbedtls_asn1_write_mpi tests with leading 1 bit
mbedtls_asn1_write_mpi() correctly handles the sign bit, so there's no
reason not to test that it's handled correctly.

Fix copypasta in test data that was commented out.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-29 11:04:48 +02:00
Gilles Peskine
06c5e929ba
Merge pull request #5863 from wernerlewis/csr_subject_comma_2.28
[Backport 2.28] Fix output of commas and other special characters in X509 DN values
2022-06-28 21:00:47 +02:00
Gilles Peskine
d0aafa6cc1
Merge pull request #5984 from gilles-peskine-arm/changelog-improvements-20220609-2.28
Changelog improvements before the 2.28.1 release
2022-06-28 21:00:12 +02:00
Gilles Peskine
83f54aad6a Changelog: minor copyediting
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-28 00:05:58 +02:00
Gilles Peskine
cd1608914f Changelog: clarify a cmake-related entry as being about cmake
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-28 00:05:50 +02:00
Gilles Peskine
8960d0585b Changelog: mention bug id in bugfix entry
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-28 00:05:50 +02:00
Gilles Peskine
06900034cb Changelog: remove bugfix entry that's actually a robustness improvement
If the key agreement or the public key export in
ssl_write_client_key_exchange() fails, the handshake enters a failed state.
The only valid thing you can do in a failed handshake is to abort it, which
calls mbedtls_ssl_handshake_free(), which destroys ecdh_psa_privey. While
it's good hygiene to destroy the key in the function that creates it, it
would have been cleaned up a little later in the normal course of things
anyway, so there wasn't an actual bug.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-28 00:05:49 +02:00
Dave Rodgman
4118092105
Merge pull request #5825 from polhenarejos/mbedtls-2.28
Backport 2.28: Fix for order value for curve448
2022-06-27 13:47:31 +01:00
Gilles Peskine
52396ef622 Remove largely useless bit of test log to silence GCC 12
GCC 12 emits a warning because it thinks `buffer1` is used after having been
freed. The code is correct C because we're only using the value of
`(uintptr_t)buffer1`, not `buffer1`. However, we aren't using the value for
anything useful: it doesn't really matter if an alloc-free-alloc sequence
returns the same address twice. So don't print that bit of information, and
this way we don't need to save the old address.

Fixes #5974.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-27 14:30:48 +02:00
Werner Lewis
1421efa25e Fix case where final special char exceeds buffer
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-06-27 12:04:43 +01:00
Werner Lewis
2ee1e2dd22 Replace parsing with outputting
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-06-27 10:03:10 +01:00
Werner Lewis
9a2356b190 Add tests for exceeded buffer size
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-06-17 16:45:24 +01:00
Dave Rodgman
46b5cb553a Add test-case for checking curve order
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-06-17 13:46:45 +01:00
Werner Lewis
02c9d3b9c2 Fix parsing of special chars in X509 DN values
Use escape mechanism defined in RFC 1779 when parsing commas and other
special characters in X509 DN values. Resolves failures when generating
a certificate with a CSR containing a comma in subject value.
Fixes #769.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-06-08 14:38:38 +01:00
Paul Elliott
7e163d796c
Merge pull request #5893 from AndrzejKurek/ssl-opt-client-kill-fix-2.28
[Backport 2.28] Fix a bug with executing ssl-client2 in ssl-opt.sh in a subshell
2022-06-08 14:26:42 +01:00
Dave Rodgman
ce02537b0c
Merge pull request #5828 from wernerlewis/time_utc_2.28
[Backport 2.28] Use ASN1 UTC tags for dates before 2000
2022-06-08 13:55:38 +01:00
Andrzej Kurek
d27cdcc16f Fix a bug with executing ssl-client2 in ssl-opt.sh in a subshell
When executing eval in the background, the next "$!" gives the
eval PID, not the ssl-client2 pid. This causes problems when
a client times out and the script tries to kill it. Instead, it
kills the parent eval call.
This caused problems with subsequent proxy tests receiving
old packets from a client from a previous test.
Moving the "&" to inside the eval call fixes the problem.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-06-06 15:12:55 -04:00
Werner Lewis
1b54a05f77 Use ASN1 UTC tags for dates before 2000
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-06-01 16:28:10 +01:00
Gilles Peskine
7bda291427
Merge pull request #5859 from paul-elliott-arm/fix_ct_uninit_memory_access_2.28
Backport 2.28: Fix uninitialised memory access in constant time functions
2022-06-01 11:42:47 +02:00
Gilles Peskine
adf225dfd6
Merge pull request #5848 from tom-daubney-arm/2-28_x25519_program
[2.28] Rewrite x25519 example program
2022-05-31 11:26:27 +02:00