1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-07 06:42:56 +03:00
Commit Graph

7617 Commits

Author SHA1 Message Date
David Horstmann
ab6175130b Fix macro-spanning if in x509_crt.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-27 11:45:01 +01:00
David Horstmann
04020abfae Fix macro-spanning ifs in ssl_ticket.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-27 11:39:03 +01:00
David Horstmann
d4f22083ba Fix macro-spanning ifs in ssl_tls.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-27 11:39:03 +01:00
David Horstmann
197b240089 Fix macro-spanning if in ssl_msg.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-27 11:39:03 +01:00
David Horstmann
ef661c531f Fix macro-spanning ifs in ecp.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-27 11:38:53 +01:00
David Horstmann
74ace59dc6 Fix macro-spanning ifs in ssl_srv.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-27 11:38:15 +01:00
Ronald Cron
c527796ecb Merge pull request #6392 from davidhorstmann-arm/2.28-fix-x509-get-name-cleanup
[Backport 2.28] Fix `mbedtls_x509_get_name()` cleanup
2022-10-26 14:28:04 +02:00
David Horstmann
ee0a0e75c8 Fix macro-spanning ifs in ssl_cli.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-25 17:20:00 +01:00
David Horstmann
e9af9e3e12 Minor improvements to ecp.c changes
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-25 16:47:56 +01:00
David Horstmann
9430330d2f Rename ARIA_SELF_TEST_IF_FAIL
Change to ARIA_SELF_TEST_ASSERT

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-25 16:47:56 +01:00
David Horstmann
864cc8dba2 Minor changes to asn1write.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-25 16:47:56 +01:00
David Horstmann
d209197f37 Refactor macro-spanning ifs in ecdh.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-25 16:47:56 +01:00
David Horstmann
b95ee00244 Refactor macro-spanning ifs in ecp.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-25 16:47:56 +01:00
David Horstmann
863b17d0cc Refactor macro-spanning if in asn1write.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-25 16:47:56 +01:00
David Horstmann
f3b1eaf95d Refactor macro-spanning if in sha512.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-25 16:47:53 +01:00
David Horstmann
5846c9de19 Refactor macro-spanning if in ssl_msg.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-25 16:43:05 +01:00
David Horstmann
0bb7243425 Refactor macro-spanning if in ssl_tls12_client.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-25 16:39:26 +01:00
David Horstmann
75b1fe7199 Refactor ARIA_SELF_TEST_IF_FAIL macro
Change the ARIA_SELF_TEST_IF_FAIL macro to be more code-style friendly.
Currently it expands to the body of an if statement, which causes
problems for automatic brace-addition for if statements.

Convert the macro to a function-like macro that takes the condition as
an argument and expands to a full if statement inside a do {} while (0)
idiom.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-25 16:36:03 +01:00
Andrzej Kurek
84fc52c6b3 Formatting & cosmetic fixes
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-25 04:18:30 -04:00
David Horstmann
670a993dcd Fix incorrect return style
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-24 15:30:30 +01:00
David Horstmann
e6917d05d3 Remove unnecessary NULL assignments
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-24 15:30:30 +01:00
David Horstmann
5ad5e1657d Clarify wording on allocation
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-24 15:30:30 +01:00
Andrzej Kurek
96298f960f Add a temporary solution to create a seedfile
This caused problems if a config with SHA512 was
compiled after a config without it and the seedfile
did not contain enough data.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-20 06:38:12 -04:00
Andrzej Kurek
dc4a25249f Fix tls 1.3 test dependencies
Remove the dependency of tls1_3 key Remove the dependency of secret evolution tests on curve25519
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-20 06:36:20 -04:00
Andrzej Kurek
b3b0ec9bed Add missing dependencies
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-20 06:22:13 -04:00
Andrzej Kurek
e8ed2a1115 Compile constant time masking and hmac if there are suites using MAC
This is used in TLS 1.2 authentication with NULL cipher,
when there are no TLS_CBC suites.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-20 06:21:50 -04:00
Andrzej Kurek
f9412f77ac Add tls prf handling when there's no SHA256 or SHA384
Return a null prf function pointer and check for it when populating transform.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-18 07:30:19 -04:00
Andrzej Kurek
8ffd8a672f Fix missing cipher mode dependencies
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-10-18 05:59:43 -04:00
Gilles Peskine
279188f3f3 Merge pull request #6396 from gilles-peskine-arm/platform.h-unconditional-2.28
Backport 2.28: Include platform.h unconditionally
2022-10-13 10:19:25 +02:00
Gilles Peskine
36b33ba42f Restore platform.h inclusion in error.c
This is an automatically generated file. The automatic processing to change
platform.h inclusion made it diverge, so put it back the way it needs to be.
platform.h is getting included once unconditionally from the fixed part of
the template, and once from the automatic enumeration of headers, which is
perfectly fine.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-07 19:49:05 +02:00
Gilles Peskine
7705a4614e Include platform.h unconditionally: gcm
gcm.c had a slightly different pattern for the conditional inclusion of
platform.h which didn't fit the general replacement. Simplify it manually.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-07 15:47:39 +02:00
Przemek Stekiel
169554c68f Adapt macro names: MBEDTLS_SSL_SOME_SUITES_USE_MAC->MBEDTLS_SSL_SOME_MODES_USE_MAC
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-06 10:53:20 +02:00
David Horstmann
8c176b487a Free structs in mbedtls_x509_get_name() on error
mbedtls_x509_get_name() allocates a linked list of mbedtls_x509_name
structs but does not free these when there is an error, leaving the
caller to free them itself. Change this to cleanup these objects within
the function in case of an error.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-05 12:57:32 +01:00
Gilles Peskine
093a4aa51b Remove useless platform macro redefinitions: automatic part
Some source files had code to set mbedtls_xxx aliases when
MBEDTLS_PLATFORM_C is not defined. These aliases are defined unconditionally
by mbedtls/platform.h, so these macro definitions were redundant. Remove
them.

This commit used the following code:
```
perl -i -0777 -pe 's~#if !defined\(MBEDTLS_PLATFORM_C\)\n(#define (mbedtls|MBEDTLS)_.*\n|#include <(stdarg|stddef|stdio|stdlib|string|time)\.h>\n)*#endif.*\n~~mg' $(git grep -l -F '#if !defined(MBEDTLS_PLATFORM_C)')
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-05 11:54:51 +02:00
Gilles Peskine
8474fe072b Include platform.h unconditionally: second automatic part
Some source files included platform.h in a nested conditional. The previous
commit "Include platform.h unconditionally: automatic part" only removed
the outer conditional. This commit removes the inner conditional.

This commit once again replaces most occurrences of conditional inclusion of
platform.h, using the following code:

```
perl -i -0777 -pe 's!#if.*\n#include "mbedtls/platform.h"\n(#else.*\n(#define (mbedtls|MBEDTLS)_.*\n|#include <(stdarg|stddef|stdio|stdlib|string|time)\.h>\n)*)?#endif.*!#include "mbedtls/platform.h"!mg' $(git grep -l '#include "mbedtls/platform.h"')
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-05 11:49:12 +02:00
Przemek Stekiel
9450dc7b6f Fix guards for mbedtls_ct_size_mask() and mbedtls_ct_memcpy_if_eq()
Both functions are used when MBEDTLS_SSL_SOME_SUITES_USE_MAC is defined not MBEDTLS_SSL_SOME_SUITES_USE_TLS_CBC.

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-05 11:38:25 +02:00
Gilles Peskine
36f19b97e2 Include platform.h unconditionally: automatic part
We used to include platform.h only when MBEDTLS_PLATFORM_C was enabled, and
to define ad hoc replacements for mbedtls_xxx functions on a case-by-case
basis when MBEDTLS_PLATFORM_C was disabled. The only reason for this
complication was to allow building individual source modules without copying
platform.h. This is not something we support or recommend anymore, so get
rid of the complication: include platform.h unconditionally.

There should be no change in behavior since just including the header should
not change the behavior of a program.

This commit replaces most occurrences of conditional inclusion of
platform.h, using the following code:

```
perl -i -0777 -pe 's!#if.*\n#include "mbedtls/platform.h"\n(#else.*\n(#define (mbedtls|MBEDTLS)_.*\n|#include <(stdarg|stddef|stdio|stdlib|string|time)\.h>\n)*)?#endif.*!#include "mbedtls/platform.h"!mg' $(git grep -l '#include "mbedtls/platform.h"')
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-05 11:26:07 +02:00
Victor Barpp Gomes
fb4723a40b Print RFC 4108 hwSerialNum in hex format
Signed-off-by: Victor Barpp Gomes <17840319+Kabbah@users.noreply.github.com>
2022-09-30 09:32:26 -03:00
Dave Rodgman
4268731b2f Fix ECDSA signature verification edge-case
For R and S equal to 1, ensure the public key is checked
for validity.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-09-23 10:42:33 +01:00
Gilles Peskine
250a612969 Merge pull request #6212 from tom-cosgrove-arm/explicit-warning-re-ct-conditions-not-0-or-1-2.28
Backport 2.28: Be explicit about constant time bignum functions that must take a 0 or 1 condition value
2022-08-22 17:24:10 +02:00
Leonid Rozenboim
81e742333e ssl_tls12_server: fix potential NULL-dereferencing if local certificate was not set.
Signed-off-by: Leonid Rozenboim <leonid.rozenboim@oracle.com>
2022-08-19 13:42:08 +01:00
Tom Cosgrove
f211d824d7 Be explicit about constant time bignum functions that must take a 0 or 1 condition value
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-08-18 14:56:00 +01:00
Gilles Peskine
f222b8e041 Merge pull request #6161 from daverodgman/backport-cert-symlink
Backport 2.28: x509_crt: handle properly broken links when looking for certificates
2022-08-03 13:05:31 +02:00
Gilles Peskine
ddc3845782 Merge pull request #6168 from mman/mbedtls-2.28
Use double quotes to include private header file psa_crypto_cipher.h
2022-08-03 13:05:00 +02:00
Martin Man
43dedd8afe Use double quotes to include private header file psa_crypto_cipher.h
Signed-off-by: Martin Man <mman@martinman.net>
Co-authored-by: Tom Cosgrove <81633263+tom-cosgrove-arm@users.noreply.github.com>
2022-08-02 13:36:18 +02:00
Dave Rodgman
6f227ee8e8 Remove use of lstat
lstat is not available on some platforms (e.g. Ubuntu 16.04). In this
particular case stat is sufficient.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-07-29 14:27:52 +01:00
Dave Rodgman
2958bb3761 Spelling and grammar improvements
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-07-29 14:27:52 +01:00
Dave Rodgman
168bcd684b Don't increase failure count for dangling symlinks
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-07-29 14:27:52 +01:00
Eduardo Silva
32ffb2b8bc x509_crt: handle properly broken links when looking for certificates
On non-windows environments, when loading certificates from a given
path through mbedtls_x509_crt_parse_path() function, if a symbolic
link is found and is broken (meaning the target file don't exists),
the function is returning MBEDTLS_ERR_X509_FILE_IO_ERROR which is
not honoring the default behavior of just skip the bad certificate file
and increase the counter of wrong files.

The problem have been raised many times in our open source project
called Fluent Bit which depends on MbedTLS:

https://github.com/fluent/fluent-bit/issues/843#issuecomment-486388209

The expected behavior is that if a simple certificate cannot be processed,
it should just be skipped.

This patch implements a workaround with lstat(2) and stat(2) to determinate
first if the entry found in the directory is a symbolic link or not, if is
a simbolic link, do a proper stat(2) for the target file, otherwise process
normally. Upon find a broken symbolic link it will increase the counter of
not processed certificates.

Signed-off-by: Eduardo Silva <eduardo@treaure-data.com>
2022-07-29 14:27:50 +01:00
Tom Cosgrove
5205c976da Fix a/an typos in doxygen and other comments
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-07-28 06:12:08 +01:00