1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-06-26 23:14:07 +08:00

7580 Commits

Author SHA1 Message Date
Dave Rodgman
705fcab9a9
Merge pull request #813 from ARMmbed/mbedtls-2.7.19-rc0-pr
Mbedtls 2.7.19 rc0 pr
mbedtls-2.7.19 v2.7.19
2021-03-09 18:01:42 +00:00
Dave Rodgman
3ad3efab44 Update Changelog for 2.7.19
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-03-08 18:24:07 +00:00
Dave Rodgman
6bbe56961a Bump version to Mbed TLS 2.7.19
Executed ./scripts/bump_version.sh --version 2.7.19

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-03-08 18:21:29 +00:00
Dave Rodgman
008e7954e8 Merge branch 'mbedtls-2.7-restricted' into mbedtls-2.7.19-rc 2021-03-08 16:45:15 +00:00
Dave Rodgman
99f4f13c0f
Merge pull request #4207 from misch7/fix-v2.7-issue-4206
Fix build of 2.7 with MBEDTLS_CERTS_C disabled in config (fixes #4206)
2021-03-08 15:16:45 +00:00
Gilles Peskine
b3961a0142 Add changelog entry
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-03-08 12:39:52 +01:00
Michael Schuster
0bf08c7274
Fix wrong closing brackets between #ifdef directives (fixes #4206)
Build of the 2.7 branch fails when MBEDTLS_CERTS_C is disabled.

The bug was introduced in PR #2498

Signed-off-by: Michael Schuster <michael@schuster.ms>
2021-03-07 06:05:04 +01:00
Manuel Pégourié-Gonnard
c466e6605d
Merge pull request #811 from paul-elliott-arm/cf_base64_work_2_7
Backport 2.7 : Constant Flow Base64 Table Access
2021-03-04 17:25:47 +01:00
Paul Elliott
38fabc4854 Code style fixups
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 14:51:41 +00:00
Paul Elliott
4d37b45c85 Fixup changelog formatting
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 14:51:19 +00:00
Paul Elliott
041836b8fc Fix misnamed base64 test
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 14:51:05 +00:00
Dave Rodgman
6a6668a944
Merge pull request #4193 from daverodgman/rsa_private_backport_2.7
Backport 2.7: Fix an incorrect error code if RSA private operation glitched
2021-03-04 12:27:42 +00:00
Janos Follath
b266edaf2b
Merge pull request #4181 from gilles-peskine-arm/net_poll-fd_setsize-2.7
Backport 2.7: Fix stack corruption in mbedtls_net_poll with large file descriptor
2021-03-04 12:15:42 +00:00
Dave Rodgman
aa616ac0e4
Merge pull request #4194 from daverodgman/test_nondet_ecdsa_backport_2.7
Test SSL with non-deterministic ECDSA
2021-03-04 11:30:01 +00:00
Paul Elliott
950ff046f2 Fix carelessly copy pasted comment
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 10:24:40 +00:00
Paul Elliott
98878ed882 Fix constant flow mask maths
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 10:24:18 +00:00
Paul Elliott
2f2ec575a5 Remove multiplication from conditional assignments
Multiplication is not constant flow on any CPU we are generally
targetting, so replace this with bit twiddling.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 10:23:39 +00:00
Paul Elliott
db932eba83 Prevent false positive CF Test Failures
Marked dirty memory ends up in the result buffer after encoding (due to
the input having been marked dirty), and then the final comparison
to make sure that we got what we expected was triggering the constant
flow checker.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 10:22:53 +00:00
Paul Elliott
98f143dd99 Add further more rigorous tests for base64
Original author was gilles.peskine@arm.com

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 10:22:40 +00:00
Paul Elliott
bd55962e3e Fix Non CF access to table in base64 decrypt
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 10:22:30 +00:00
Paul Elliott
419983da23 Optimise unneccesary cf table accesses away
Also fix missed bare access of base_64_dec_map

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 10:21:31 +00:00
Paul Elliott
eb3916d6b0 Fix incorrect assumptions about the size of size_t
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 10:21:16 +00:00
Paul Elliott
aae04efcfc Fixes for MSVC warnings
Also added a couple of missing comment blocks.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 10:20:56 +00:00
Paul Elliott
6eb6f50119 Add Changelog entry
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 10:20:30 +00:00
Paul Elliott
d67029df26 First pass at constant flow tests for base64
This contains working CF tests for encode, however I have not yet got
decode to pass the tests.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 10:19:46 +00:00
Paul Elliott
aa5027984c Attempt to make Base64 table access constant flow
Add constant flow table access code, and use that exclusively to access
the base64 lookup table

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-03-04 09:59:31 +00:00
Gilles Peskine
ea4cc855e2 Test SSL with non-deterministic ECDSA
In component_test_no_hmac_drbg, the fact that HMAC_DRBG is disabled
doesn't affect the SSL code, but the fact that deterministic ECDSA is
disabled does. So run some ECDSA-related SSL tests.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-03-03 16:43:19 +00:00
Gilles Peskine
fc2c79633b Fix an incorrect error code if RSA private operation glitched
mbedtls_rsa_private() could return the sum of two RSA error codes
instead of a valid error code in some rare circumstances:

* If rsa_prepare_blinding() returned  MBEDTLS_ERR_RSA_RNG_FAILED
  (indicating a misbehaving or misconfigured RNG).
* If the comparison with the public value failed (typically indicating
  a glitch attack).

Make sure not to add two high-level error codes.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-03-03 16:19:09 +00:00
Gilles Peskine
51f5d31635 Update error codes listed in the net_sockets documentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-03-03 12:25:06 +01:00
Gilles Peskine
f02eeb8762 Fix sloppy wording around stricly less-than vs less or equal
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-03-03 12:23:27 +01:00
Gilles Peskine
51917a82e8 Document FD_SETSIZE limitation for mbedtls_net_recv_timeout
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-03-03 12:23:27 +01:00
Gilles Peskine
33d816aff9 Fix stack buffer overflow in net functions with large file descriptor
Fix a stack buffer overflow with mbedtls_net_recv_timeout() when given a
file descriptor that is beyond FD_SETSIZE. The bug was due to not checking
that the file descriptor is within the range of an fd_set object.

Fix #4169

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-03-03 12:23:27 +01:00
Gilles Peskine
9c1ae18c9c
Merge pull request #4090 from gilles-peskine-arm/test-mutex-usage-count-2.7
Backport 2.7: test and fix mutex usage
2021-02-23 15:14:53 +01:00
Gilles Peskine
2de4691bb0 Make entropy double-free work
Although the library documentation does not guarantee that calling
mbedtls_entropy_free() twice works, it's a plausible assumption and it's
natural to write code that frees an object twice. While this is uncommon for
an entropy context, which is usually a global variable, it came up in our
own unit tests (random_twice tests in test_suite_random in the
development branch).

Announce this in the same changelog entry as for RSA because it's the same
bug in the two modules.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-23 11:28:19 +01:00
Gilles Peskine
9f97f95225 Add init-free tests for entropy
These tests validate that an entropy object can be reused and that
calling mbedtls_entropy_free() twice is ok.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-23 11:25:07 +01:00
Gilles Peskine
58a39e02da Fix typo in documentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-15 18:21:55 +01:00
Gilles Peskine
e8505e37df Document mutex usage for RSA
The mutex is now initialized iff ver != 0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 16:19:35 +01:00
Gilles Peskine
3be78f318c Changelog entry for RSA mutex usage fix
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 16:19:12 +01:00
Gilles Peskine
22dc2e7a9b Fix mutex leak in RSA
mbedtls_rsa_gen_key() was not freeing the RSA object, and specifically
not freeing the mutex, in some error cases.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 15:57:03 +01:00
Gilles Peskine
d7e82ad9bf Fix mutex double-free in RSA
When MBEDTLS_THREADING_C is enabled, RSA code protects the use of the
key with a mutex. mbedtls_rsa_free() frees this mutex by calling
mbedtls_mutex_free(). This does not match the usage of
mbedtls_mutex_free(), which in general can only be done once.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 15:57:03 +01:00
Gilles Peskine
54e7e2bdc7 Add init-free tests for RSA
These tests are trivial except when compiling with MBEDTLS_THREADING_C
and a mutex implementation that are picky about matching each
mbedtls_mutex_init() with exactly one mbedtls_mutex_free().

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 15:57:03 +01:00
Gilles Peskine
ff754e67ae Add missing cleanup in a test function
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 15:57:03 +01:00
Gilles Peskine
e525bc830f Changelog entry for DRBG mutex usage fix
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 15:57:03 +01:00
Gilles Peskine
94bf03330b Document thread safety for HMAC_DRBG
random(), and only this function, is thread-safe.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 15:57:03 +01:00
Gilles Peskine
3ec7f57482 Document mutex invariant for HMAC_DRBG
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 15:57:03 +01:00
Gilles Peskine
a9857af16a Fix mutex leak in HMAC_DRBG
mbedtls_hmac_drbg_free() left a mutex in the initialized state. This
caused a resource leak on platforms where mbedtls_mutex_init()
allocates resources.

To fix this, mbedtls_hmac_drbg_free() no longer reinitializes the
mutex. To preserve the property that mbedtls_hmac_drbg_free() leaves
the object in an initialized state, which is generally true throughout
the library except regarding mutex objects on some platforms, no
longer initialize the mutex in mbedtls_hmac_drbg_init(). Since the
mutex is only used after seeding, and seeding is only permitted once,
call mbedtls_mutex_init() as part of the seeding process.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 15:57:03 +01:00
Gilles Peskine
275598d3fa Document thread safety for CTR_DRBG
random(), and only this function, is thread-safe.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 15:57:03 +01:00
Gilles Peskine
6e2cf25639 Document mutex invariant for CTR_DRBG
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 15:57:03 +01:00
Gilles Peskine
085b69f8fd Fix mutex leak in CTR_DRBG
mbedtls_ctr_drbg_free() left a mutex in the initialized state. This
caused a resource leak on platforms where mbedtls_mutex_init()
allocates resources.

To fix this, mbedtls_ctr_drbg_free() no longer reinitializes the
mutex. To preserve the property that mbedtls_ctr_drbg_free() leaves
the object in an initialized state, which is generally true throughout
the library except regarding mutex objects on some platforms, no
longer initialize the mutex in mbedtls_ctr_drbg_init(). Since the
mutex is only used after seeding, and seeding is only permitted once,
call mbedtls_mutex_init() as part of the seeding process.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 15:57:03 +01:00
Gilles Peskine
5710732145 Explain the usage of is_valid in pthread mutexes
Document the usage inside the library, and relate it with how it's
additionally used in the test code.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-12 15:57:03 +01:00