mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 17:55:40 +01:00
Merge pull request #710 from ARMmbed/mbedtls-2.23.0r0-pr
Prepare Release Candidate for Mbed TLS 2.23.0
This commit is contained in:
commit
3ede1737dc
123
ChangeLog
123
ChangeLog
@ -1,5 +1,128 @@
|
|||||||
mbed TLS ChangeLog (Sorted per branch, date)
|
mbed TLS ChangeLog (Sorted per branch, date)
|
||||||
|
|
||||||
|
= mbed TLS 2.23.0 branch released 2020-07-01
|
||||||
|
|
||||||
|
Default behavior changes
|
||||||
|
* In the experimental PSA secure element interface, change the encoding of
|
||||||
|
key lifetimes to encode a persistence level and the location. Although C
|
||||||
|
prototypes do not effectively change, code calling
|
||||||
|
psa_register_se_driver() must be modified to pass the driver's location
|
||||||
|
instead of the keys' lifetime. If the library is upgraded on an existing
|
||||||
|
device, keys created with the old lifetime value will not be readable or
|
||||||
|
removable through Mbed TLS after the upgrade.
|
||||||
|
|
||||||
|
Features
|
||||||
|
* New functions in the error module return constant strings for
|
||||||
|
high- and low-level error codes, complementing mbedtls_strerror()
|
||||||
|
which constructs a string for any error code, including compound
|
||||||
|
ones, but requires a writable buffer. Contributed by Gaurav Aggarwal
|
||||||
|
in #3176.
|
||||||
|
* The new utility programs/ssl/ssl_context_info prints a human-readable
|
||||||
|
dump of an SSL context saved with mbedtls_ssl_context_save().
|
||||||
|
* Add support for midipix, a POSIX layer for Microsoft Windows.
|
||||||
|
* Add new mbedtls_x509_crt_parse_der_with_ext_cb() routine which allows
|
||||||
|
parsing unsupported certificate extensions via user provided callback.
|
||||||
|
Contributed by Nicola Di Lieto <nicola.dilieto@gmail.com> in #3243 as
|
||||||
|
a solution to #3241.
|
||||||
|
* Pass the "certificate policies" extension to the callback supplied to
|
||||||
|
mbedtls_x509_crt_parse_der_with_ext_cb() if it contains unsupported
|
||||||
|
policies (#3419).
|
||||||
|
* Added support to entropy_poll for the kern.arandom syscall supported on
|
||||||
|
some BSD systems. Contributed by Nia Alarie in #3423.
|
||||||
|
* Add support for Windows 2000 in net_sockets. Contributed by opatomic. #3239
|
||||||
|
|
||||||
|
Security
|
||||||
|
* Fix a side channel vulnerability in modular exponentiation that could
|
||||||
|
reveal an RSA private key used in a secure enclave. Noticed by Sangho Lee,
|
||||||
|
Ming-Wei Shih, Prasun Gera, Taesoo Kim and Hyesoon Kim (Georgia Institute
|
||||||
|
of Technology); and Marcus Peinado (Microsoft Research). Reported by Raoul
|
||||||
|
Strackx (Fortanix) in #3394.
|
||||||
|
* Fix side channel in mbedtls_ecp_check_pub_priv() and
|
||||||
|
mbedtls_pk_parse_key() / mbedtls_pk_parse_keyfile() (when loading a
|
||||||
|
private key that didn't include the uncompressed public key), as well as
|
||||||
|
mbedtls_ecp_mul() / mbedtls_ecp_mul_restartable() when called with a NULL
|
||||||
|
f_rng argument. An attacker with access to precise enough timing and
|
||||||
|
memory access information (typically an untrusted operating system
|
||||||
|
attacking a secure enclave) could fully recover the ECC private key.
|
||||||
|
Found and reported by Alejandro Cabrera Aldaya and Billy Brumley.
|
||||||
|
* Fix issue in Lucky 13 counter-measure that could make it ineffective when
|
||||||
|
hardware accelerators were used (using one of the MBEDTLS_SHAxxx_ALT
|
||||||
|
macros). This would cause the original Lucky 13 attack to be possible in
|
||||||
|
those configurations, allowing an active network attacker to recover
|
||||||
|
plaintext after repeated timing measurements under some conditions.
|
||||||
|
Reported and fix suggested by Luc Perneel in #3246.
|
||||||
|
|
||||||
|
Bugfix
|
||||||
|
* Fix the Visual Studio Release x64 build configuration for mbedtls itself.
|
||||||
|
Completes a previous fix in Mbed TLS 2.19 that only fixed the build for
|
||||||
|
the example programs. Reported in #1430 and fix contributed by irwir.
|
||||||
|
* Fix undefined behavior in X.509 certificate parsing if the
|
||||||
|
pathLenConstraint basic constraint value is equal to INT_MAX.
|
||||||
|
The actual effect with almost every compiler is the intended
|
||||||
|
behavior, so this is unlikely to be exploitable anywhere. #3192
|
||||||
|
* Fix issue with a detected HW accelerated record error not being exposed
|
||||||
|
due to shadowed variable. Contributed by Sander Visser in #3310.
|
||||||
|
* Avoid NULL pointer dereferencing if mbedtls_ssl_free() is called with a
|
||||||
|
NULL pointer argument. Contributed by Sander Visser in #3312.
|
||||||
|
* Fix potential linker errors on dual world platforms by inlining
|
||||||
|
mbedtls_gcc_group_to_psa(). This allows the pk.c module to link separately
|
||||||
|
from psa_crypto.c. Fixes #3300.
|
||||||
|
* Remove dead code in X.509 certificate parsing. Contributed by irwir in
|
||||||
|
#2855.
|
||||||
|
* Include asn1.h in error.c. Fixes #3328 reported by David Hu.
|
||||||
|
* Fix potential memory leaks in ecp_randomize_jac() and ecp_randomize_mxz()
|
||||||
|
when PRNG function fails. Contributed by Jonas Lejeune in #3318.
|
||||||
|
* Remove unused macros from MSVC projects. Reported in #3297 and fix
|
||||||
|
submitted in #3333 by irwir.
|
||||||
|
* Add additional bounds checks in ssl_write_client_hello() preventing
|
||||||
|
output buffer overflow if the configuration declared a buffer that was
|
||||||
|
too small.
|
||||||
|
* Set _POSIX_C_SOURCE to at least 200112L in C99 code. Reported in #3420 and
|
||||||
|
fix submitted in #3421 by Nia Alarie.
|
||||||
|
* Fix building library/net_sockets.c and the ssl_mail_client program on
|
||||||
|
NetBSD. Contributed by Nia Alarie in #3422.
|
||||||
|
* Fix false positive uninitialised variable reported by cpp-check.
|
||||||
|
Contributed by Sander Visser in #3311.
|
||||||
|
* Update iv and len context pointers manually when reallocating buffers
|
||||||
|
using the MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH feature. This caused issues
|
||||||
|
when receiving a connection with CID, when these fields were shifted
|
||||||
|
in ssl_parse_record_header().
|
||||||
|
|
||||||
|
Changes
|
||||||
|
* Fix warnings about signedness issues in format strings. The build is now
|
||||||
|
clean of -Wformat-signedness warnings. Contributed by Kenneth Soerensen
|
||||||
|
in #3153.
|
||||||
|
* Fix minor performance issue in operations on Curve25519 caused by using a
|
||||||
|
suboptimal modular reduction in one place. Found and fix contributed by
|
||||||
|
Aurelien Jarno in #3209.
|
||||||
|
* Combine identical cases in switch statements in md.c. Contributed
|
||||||
|
by irwir in #3208.
|
||||||
|
* Simplify a bounds check in ssl_write_certificate_request(). Contributed
|
||||||
|
by irwir in #3150.
|
||||||
|
* Unify the example programs termination to call mbedtls_exit() instead of
|
||||||
|
using a return command. This has been done to enable customization of the
|
||||||
|
behavior in bare metal environments.
|
||||||
|
* Fix mbedtls_x509_dn_gets to escape non-ASCII characters as "?".
|
||||||
|
Contributed by Koh M. Nakagawa in #3326.
|
||||||
|
* Use FindPython3 when cmake version >= 3.15.0
|
||||||
|
* Abort the ClientHello writing function as soon as some extension doesn't
|
||||||
|
fit into the record buffer. Previously, such extensions were silently
|
||||||
|
dropped. As a consequence, the TLS handshake now fails when the output
|
||||||
|
buffer is not large enough to hold the ClientHello.
|
||||||
|
* The unit tests now rely on header files in tests/include/test and source
|
||||||
|
files in tests/src. When building with make or cmake, the files in
|
||||||
|
tests/src are compiled and the resulting object linked into each test
|
||||||
|
executable.
|
||||||
|
* The ECP module, enabled by `MBEDTLS_ECP_C`, now depends on
|
||||||
|
`MBEDTLS_CTR_DRBG_C` or `MBEDTLS_HMAC_DRBG_C` for some side-channel
|
||||||
|
coutermeasures. If side channels are not a concern, this dependency can
|
||||||
|
be avoided by enabling the new option `MBEDTLS_ECP_NO_INTERNAL_RNG`.
|
||||||
|
* Align MSVC error flag with GCC and Clang. Contributed by Carlos Gomes
|
||||||
|
Martinho. #3147
|
||||||
|
* Remove superfluous assignment in mbedtls_ssl_parse_certificate(). Reported
|
||||||
|
in #3182 and fix submitted by irwir. #3217
|
||||||
|
* Fix typo in XTS tests. Reported and fix submitted by Kxuan. #3319
|
||||||
|
|
||||||
= mbed TLS 2.22.0 branch released 2020-04-14
|
= mbed TLS 2.22.0 branch released 2020-04-14
|
||||||
|
|
||||||
New deprecations
|
New deprecations
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Fix the Visual Studio Release x64 build configuration for mbedtls itself.
|
|
||||||
Completes a previous fix in Mbed TLS 2.19 that only fixed the build for
|
|
||||||
the example programs. Reported in #1430 and fix contributed by irwir.
|
|
@ -1,2 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Remove dead code in X.509 certificate parsing. Contributed by irwir in #2855.
|
|
@ -1,2 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Remove unused macros from MSVC projects. Reported in #3297 and fix submitted in #3333 by irwir.
|
|
@ -1,5 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Update iv and len context pointers manually when reallocating buffers
|
|
||||||
using the MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH feature. This caused issues
|
|
||||||
when receiving a connection with CID, when these fields were shifted
|
|
||||||
in ssl_parse_record_header().
|
|
@ -1,2 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Set _POSIX_C_SOURCE to at least 200112L in C99 code. Reported in #3420 and fix submitted in #3421 by Nia Alarie.
|
|
@ -1,2 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Fix building library/net_sockets.c and the ssl_mail_client program on NetBSD. Contributed by Nia Alarie in #3422.
|
|
@ -1,2 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Include asn1.h in error.c. Fixes #3328 reported by David Hu.
|
|
@ -1,6 +0,0 @@
|
|||||||
Features
|
|
||||||
* New functions in the error module return constant strings for
|
|
||||||
high- and low-level error codes, complementing mbedtls_strerror()
|
|
||||||
which constructs a string for any error code, including compound
|
|
||||||
ones, but requires a writable buffer. Contributed by Gaurav Aggarwal
|
|
||||||
in #3176.
|
|
@ -1,3 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Fix potential memory leaks in ecp_randomize_jac() and ecp_randomize_mxz()
|
|
||||||
when PRNG function fails. Contributed by Jonas Lejeune in #3318.
|
|
@ -1,4 +0,0 @@
|
|||||||
Changes
|
|
||||||
* Fix minor performance issue in operations on Curve25519 caused by using a
|
|
||||||
suboptimal modular reduction in one place. Found and fix contributed by
|
|
||||||
Aurelien Jarno in #3209.
|
|
@ -1,4 +0,0 @@
|
|||||||
Changes
|
|
||||||
* Fix warnings about signedness issues in format strings. The build is now
|
|
||||||
clean of -Wformat-signedness warnings. Contributed by Kenneth Soerensen
|
|
||||||
in #3153.
|
|
@ -1,3 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Fix issue with a detected HW accelerated record error not being exposed
|
|
||||||
due to shadowed variable. Contributed by Sander Visser in #3310.
|
|
@ -1,3 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Avoid NULL pointer dereferencing if mbedtls_ssl_free() is called with a
|
|
||||||
NULL pointer argument. Contributed by Sander Visser in #3312.
|
|
@ -1,3 +0,0 @@
|
|||||||
Changes
|
|
||||||
* Fix mbedtls_x509_dn_gets to escape non-ASCII characters as "?".
|
|
||||||
Contributed by Koh M. Nakagawa in #3326.
|
|
@ -1,4 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Fix potential linker errors on dual world platforms by inlining
|
|
||||||
mbedtls_gcc_group_to_psa(). This allows the pk.c module to link separately
|
|
||||||
from psa_crypto.c. Fixes #3300.
|
|
@ -1,5 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Fix undefined behavior in X.509 certificate parsing if the
|
|
||||||
pathLenConstraint basic constraint value is equal to INT_MAX.
|
|
||||||
The actual effect with almost every compiler is the intended
|
|
||||||
behavior, so this is unlikely to be exploitable anywhere. #3192
|
|
@ -1,3 +0,0 @@
|
|||||||
Changes
|
|
||||||
* Combine identical cases in switch statements in md.c. Contributed
|
|
||||||
by irwir in #3208.
|
|
@ -1,2 +0,0 @@
|
|||||||
Features
|
|
||||||
* Add support for midipix, a POSIX layer for Microsoft Windows.
|
|
@ -1,6 +0,0 @@
|
|||||||
Security
|
|
||||||
* Fix a side channel vulnerability in modular exponentiation that could
|
|
||||||
reveal an RSA private key used in a secure enclave. Noticed by Sangho Lee,
|
|
||||||
Ming-Wei Shih, Prasun Gera, Taesoo Kim and Hyesoon Kim (Georgia Institute
|
|
||||||
of Technology); and Marcus Peinado (Microsoft Research). Reported by Raoul
|
|
||||||
Strackx (Fortanix) in #3394.
|
|
@ -1,5 +0,0 @@
|
|||||||
Features
|
|
||||||
* Add new mbedtls_x509_crt_parse_der_with_ext_cb() routine which allows
|
|
||||||
parsing unsupported certificate extensions via user provided callback.
|
|
||||||
Contributed by Nicola Di Lieto <nicola.dilieto@gmail.com> in #3243 as
|
|
||||||
a solution to #3241.
|
|
@ -1,4 +0,0 @@
|
|||||||
Features
|
|
||||||
* Pass the "certificate policies" extension to the callback supplied to
|
|
||||||
mbedtls_x509_crt_parse_der_with_ext_cb() if it contains unsupported
|
|
||||||
policies (#3419).
|
|
@ -1,8 +0,0 @@
|
|||||||
Default behavior changes
|
|
||||||
* In the experimental PSA secure element interface, change the encoding of
|
|
||||||
key lifetimes to encode a persistence level and the location. Although C
|
|
||||||
prototypes do not effectively change, code calling
|
|
||||||
psa_register_se_driver() must be modified to pass the driver's location
|
|
||||||
instead of the keys' lifetime. If the library is upgraded on an existing
|
|
||||||
device, keys created with the old lifetime value will not be readable or
|
|
||||||
removable through Mbed TLS after the upgrade.
|
|
@ -1,3 +0,0 @@
|
|||||||
Features
|
|
||||||
* The new utility programs/ssl/ssl_context_info prints a human-readable
|
|
||||||
dump of an SSL context saved with mbedtls_ssl_context_save().
|
|
@ -1,3 +0,0 @@
|
|||||||
Changes
|
|
||||||
* Simplify a bounds check in ssl_write_certificate_request(). Contributed
|
|
||||||
by irwir in #3150.
|
|
@ -1,2 +0,0 @@
|
|||||||
Features
|
|
||||||
* Added support to entropy_poll for the kern.arandom syscall supported on some BSD systems. Contributed by Nia Alarie in #3423.
|
|
@ -1,5 +0,0 @@
|
|||||||
Changes
|
|
||||||
* The unit tests now rely on header files in tests/include/test and source
|
|
||||||
files in tests/src. When building with make or cmake, the files in
|
|
||||||
tests/src are compiled and the resulting object linked into each test
|
|
||||||
executable.
|
|
@ -1,4 +0,0 @@
|
|||||||
Changes
|
|
||||||
* Unify the example programs termination to call mbedtls_exit() instead of
|
|
||||||
using a return command. This has been done to enable customization of the
|
|
||||||
behavior in bare metal environments.
|
|
@ -1,9 +0,0 @@
|
|||||||
Bugfix
|
|
||||||
* Add additional bounds checks in ssl_write_client_hello() preventing
|
|
||||||
output buffer overflow if the configuration declared a buffer that was
|
|
||||||
too small.
|
|
||||||
Changes
|
|
||||||
* Abort the ClientHello writing function as soon as some extension doesn't
|
|
||||||
fit into the record buffer. Previously, such extensions were silently
|
|
||||||
dropped. As a consequence, the TLS handshake now fails when the output
|
|
||||||
buffer is not large enough to hold the ClientHello.
|
|
@ -1,2 +0,0 @@
|
|||||||
Changes
|
|
||||||
* Use FindPython3 when cmake version >= 3.15.0
|
|
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mainpage mbed TLS v2.22.0 source code documentation
|
* @mainpage mbed TLS v2.23.0 source code documentation
|
||||||
*
|
*
|
||||||
* This documentation describes the internal structure of mbed TLS. It was
|
* This documentation describes the internal structure of mbed TLS. It was
|
||||||
* automatically generated from specially formatted comment blocks in
|
* automatically generated from specially formatted comment blocks in
|
||||||
|
@ -28,7 +28,7 @@ DOXYFILE_ENCODING = UTF-8
|
|||||||
# identify the project. Note that if you do not use Doxywizard you need
|
# identify the project. Note that if you do not use Doxywizard you need
|
||||||
# to put quotes around the project name if it contains spaces.
|
# to put quotes around the project name if it contains spaces.
|
||||||
|
|
||||||
PROJECT_NAME = "mbed TLS v2.22.0"
|
PROJECT_NAME = "mbed TLS v2.23.0"
|
||||||
|
|
||||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
|
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
|
||||||
# This could be handy for archiving the generated documentation or
|
# This could be handy for archiving the generated documentation or
|
||||||
|
@ -156,6 +156,14 @@
|
|||||||
#error "MBEDTLS_ECP_C defined, but not all prerequisites"
|
#error "MBEDTLS_ECP_C defined, but not all prerequisites"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_ECP_C) && !( \
|
||||||
|
defined(MBEDTLS_ECP_ALT) || \
|
||||||
|
defined(MBEDTLS_CTR_DRBG_C) || \
|
||||||
|
defined(MBEDTLS_HMAC_DRBG_C) || \
|
||||||
|
defined(MBEDTLS_ECP_NO_INTERNAL_RNG))
|
||||||
|
#error "MBEDTLS_ECP_C requires a DRBG module unless MBEDTLS_ECP_NO_INTERNAL_RNG is defined or an alternative implementation is used"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_ASN1_PARSE_C)
|
#if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_ASN1_PARSE_C)
|
||||||
#error "MBEDTLS_PK_PARSE_C defined, but not all prerequesites"
|
#error "MBEDTLS_PK_PARSE_C defined, but not all prerequesites"
|
||||||
#endif
|
#endif
|
||||||
|
@ -781,6 +781,28 @@
|
|||||||
*/
|
*/
|
||||||
#define MBEDTLS_ECP_NIST_OPTIM
|
#define MBEDTLS_ECP_NIST_OPTIM
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \def MBEDTLS_ECP_NO_INTERNAL_RNG
|
||||||
|
*
|
||||||
|
* When this option is disabled, mbedtls_ecp_mul() will make use of an
|
||||||
|
* internal RNG when called with a NULL \c f_rng argument, in order to protect
|
||||||
|
* against some side-channel attacks.
|
||||||
|
*
|
||||||
|
* This protection introduces a dependency of the ECP module on one of the
|
||||||
|
* DRBG modules. For very constrained implementations that don't require this
|
||||||
|
* protection (for example, because you're only doing signature verification,
|
||||||
|
* so not manipulating any secret, or because local/physical side-channel
|
||||||
|
* attacks are outside your threat model), it might be desirable to get rid of
|
||||||
|
* that dependency.
|
||||||
|
*
|
||||||
|
* \warning Enabling this option makes some uses of ECP vulnerable to some
|
||||||
|
* side-channel attacks. Only enable it if you know that's not a problem for
|
||||||
|
* your use case.
|
||||||
|
*
|
||||||
|
* Uncomment this macro to disable some counter-measures in ECP.
|
||||||
|
*/
|
||||||
|
//#define MBEDTLS_ECP_NO_INTERNAL_RNG
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \def MBEDTLS_ECP_RESTARTABLE
|
* \def MBEDTLS_ECP_RESTARTABLE
|
||||||
*
|
*
|
||||||
|
@ -846,6 +846,9 @@ int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp,
|
|||||||
* intermediate results to prevent potential timing attacks
|
* intermediate results to prevent potential timing attacks
|
||||||
* targeting these results. We recommend always providing
|
* targeting these results. We recommend always providing
|
||||||
* a non-NULL \p f_rng. The overhead is negligible.
|
* a non-NULL \p f_rng. The overhead is negligible.
|
||||||
|
* Note: unless #MBEDTLS_ECP_NO_INTERNAL_RNG is defined, when
|
||||||
|
* \p f_rng is NULL, an internal RNG (seeded from the value
|
||||||
|
* of \p m) will be used instead.
|
||||||
*
|
*
|
||||||
* \param grp The ECP group to use.
|
* \param grp The ECP group to use.
|
||||||
* This must be initialized and have group parameters
|
* This must be initialized and have group parameters
|
||||||
|
@ -104,6 +104,8 @@ typedef struct mbedtls_md_context_t
|
|||||||
* \brief This function returns the list of digests supported by the
|
* \brief This function returns the list of digests supported by the
|
||||||
* generic digest module.
|
* generic digest module.
|
||||||
*
|
*
|
||||||
|
* \note The list starts with the strongest available hashes.
|
||||||
|
*
|
||||||
* \return A statically allocated array of digests. Each element
|
* \return A statically allocated array of digests. Each element
|
||||||
* in the returned list is an integer belonging to the
|
* in the returned list is an integer belonging to the
|
||||||
* message-digest enumeration #mbedtls_md_type_t.
|
* message-digest enumeration #mbedtls_md_type_t.
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
* Major, Minor, Patchlevel
|
* Major, Minor, Patchlevel
|
||||||
*/
|
*/
|
||||||
#define MBEDTLS_VERSION_MAJOR 2
|
#define MBEDTLS_VERSION_MAJOR 2
|
||||||
#define MBEDTLS_VERSION_MINOR 22
|
#define MBEDTLS_VERSION_MINOR 23
|
||||||
#define MBEDTLS_VERSION_PATCH 0
|
#define MBEDTLS_VERSION_PATCH 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,9 +47,9 @@
|
|||||||
* MMNNPP00
|
* MMNNPP00
|
||||||
* Major version | Minor version | Patch version
|
* Major version | Minor version | Patch version
|
||||||
*/
|
*/
|
||||||
#define MBEDTLS_VERSION_NUMBER 0x02160000
|
#define MBEDTLS_VERSION_NUMBER 0x02170000
|
||||||
#define MBEDTLS_VERSION_STRING "2.22.0"
|
#define MBEDTLS_VERSION_STRING "2.23.0"
|
||||||
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.22.0"
|
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.23.0"
|
||||||
|
|
||||||
#if defined(MBEDTLS_VERSION_C)
|
#if defined(MBEDTLS_VERSION_C)
|
||||||
|
|
||||||
|
@ -181,19 +181,19 @@ endif(USE_STATIC_MBEDTLS_LIBRARY)
|
|||||||
if(USE_SHARED_MBEDTLS_LIBRARY)
|
if(USE_SHARED_MBEDTLS_LIBRARY)
|
||||||
|
|
||||||
add_library(mbedcrypto SHARED ${src_crypto})
|
add_library(mbedcrypto SHARED ${src_crypto})
|
||||||
set_target_properties(mbedcrypto PROPERTIES VERSION 2.22.0 SOVERSION 4)
|
set_target_properties(mbedcrypto PROPERTIES VERSION 2.23.0 SOVERSION 5)
|
||||||
target_link_libraries(mbedcrypto ${libs})
|
target_link_libraries(mbedcrypto ${libs})
|
||||||
target_include_directories(mbedcrypto
|
target_include_directories(mbedcrypto
|
||||||
PUBLIC ${MBEDTLS_DIR}/include/)
|
PUBLIC ${MBEDTLS_DIR}/include/)
|
||||||
|
|
||||||
add_library(mbedx509 SHARED ${src_x509})
|
add_library(mbedx509 SHARED ${src_x509})
|
||||||
set_target_properties(mbedx509 PROPERTIES VERSION 2.22.0 SOVERSION 1)
|
set_target_properties(mbedx509 PROPERTIES VERSION 2.23.0 SOVERSION 1)
|
||||||
target_link_libraries(mbedx509 ${libs} mbedcrypto)
|
target_link_libraries(mbedx509 ${libs} mbedcrypto)
|
||||||
target_include_directories(mbedx509
|
target_include_directories(mbedx509
|
||||||
PUBLIC ${MBEDTLS_DIR}/include/)
|
PUBLIC ${MBEDTLS_DIR}/include/)
|
||||||
|
|
||||||
add_library(mbedtls SHARED ${src_tls})
|
add_library(mbedtls SHARED ${src_tls})
|
||||||
set_target_properties(mbedtls PROPERTIES VERSION 2.22.0 SOVERSION 13)
|
set_target_properties(mbedtls PROPERTIES VERSION 2.23.0 SOVERSION 13)
|
||||||
target_link_libraries(mbedtls ${libs} mbedx509)
|
target_link_libraries(mbedtls ${libs} mbedx509)
|
||||||
target_include_directories(mbedtls
|
target_include_directories(mbedtls
|
||||||
PUBLIC ${MBEDTLS_DIR}/include/)
|
PUBLIC ${MBEDTLS_DIR}/include/)
|
||||||
|
@ -37,7 +37,7 @@ endif
|
|||||||
|
|
||||||
SOEXT_TLS=so.13
|
SOEXT_TLS=so.13
|
||||||
SOEXT_X509=so.1
|
SOEXT_X509=so.1
|
||||||
SOEXT_CRYPTO=so.4
|
SOEXT_CRYPTO=so.5
|
||||||
|
|
||||||
# Set AR_DASH= (empty string) to use an ar implementation that does not accept
|
# Set AR_DASH= (empty string) to use an ar implementation that does not accept
|
||||||
# the - prefix for command line options (e.g. llvm-ar)
|
# the - prefix for command line options (e.g. llvm-ar)
|
||||||
|
229
library/ecp.c
229
library/ecp.c
@ -105,6 +105,16 @@
|
|||||||
|
|
||||||
#include "mbedtls/ecp_internal.h"
|
#include "mbedtls/ecp_internal.h"
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
#if defined(MBEDTLS_HMAC_DRBG_C)
|
||||||
|
#include "mbedtls/hmac_drbg.h"
|
||||||
|
#elif defined(MBEDTLS_CTR_DRBG_C)
|
||||||
|
#include "mbedtls/ctr_drbg.h"
|
||||||
|
#else
|
||||||
|
#error "Invalid configuration detected. Include check_config.h to ensure that the configuration is valid."
|
||||||
|
#endif
|
||||||
|
#endif /* MBEDTLS_ECP_NO_INTERNAL_RNG */
|
||||||
|
|
||||||
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
|
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
|
||||||
!defined(inline) && !defined(__cplusplus)
|
!defined(inline) && !defined(__cplusplus)
|
||||||
#define inline __inline
|
#define inline __inline
|
||||||
@ -118,6 +128,144 @@
|
|||||||
static unsigned long add_count, dbl_count, mul_count;
|
static unsigned long add_count, dbl_count, mul_count;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
/*
|
||||||
|
* Currently ecp_mul() takes a RNG function as an argument, used for
|
||||||
|
* side-channel protection, but it can be NULL. The initial reasoning was
|
||||||
|
* that people will pass non-NULL RNG when they care about side-channels, but
|
||||||
|
* unfortunately we have some APIs that call ecp_mul() with a NULL RNG, with
|
||||||
|
* no opportunity for the user to do anything about it.
|
||||||
|
*
|
||||||
|
* The obvious strategies for addressing that include:
|
||||||
|
* - change those APIs so that they take RNG arguments;
|
||||||
|
* - require a global RNG to be available to all crypto modules.
|
||||||
|
*
|
||||||
|
* Unfortunately those would break compatibility. So what we do instead is
|
||||||
|
* have our own internal DRBG instance, seeded from the secret scalar.
|
||||||
|
*
|
||||||
|
* The following is a light-weight abstraction layer for doing that with
|
||||||
|
* HMAC_DRBG (first choice) or CTR_DRBG.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_HMAC_DRBG_C)
|
||||||
|
|
||||||
|
/* DRBG context type */
|
||||||
|
typedef mbedtls_hmac_drbg_context ecp_drbg_context;
|
||||||
|
|
||||||
|
/* DRBG context init */
|
||||||
|
static inline void ecp_drbg_init( ecp_drbg_context *ctx )
|
||||||
|
{
|
||||||
|
mbedtls_hmac_drbg_init( ctx );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* DRBG context free */
|
||||||
|
static inline void ecp_drbg_free( ecp_drbg_context *ctx )
|
||||||
|
{
|
||||||
|
mbedtls_hmac_drbg_free( ctx );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* DRBG function */
|
||||||
|
static inline int ecp_drbg_random( void *p_rng,
|
||||||
|
unsigned char *output, size_t output_len )
|
||||||
|
{
|
||||||
|
return( mbedtls_hmac_drbg_random( p_rng, output, output_len ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* DRBG context seeding */
|
||||||
|
static int ecp_drbg_seed( ecp_drbg_context *ctx,
|
||||||
|
const mbedtls_mpi *secret, size_t secret_len )
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
unsigned char secret_bytes[MBEDTLS_ECP_MAX_BYTES];
|
||||||
|
/* The list starts with strong hashes */
|
||||||
|
const mbedtls_md_type_t md_type = mbedtls_md_list()[0];
|
||||||
|
const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( md_type );
|
||||||
|
|
||||||
|
if( secret_len > MBEDTLS_ECP_MAX_BYTES )
|
||||||
|
{
|
||||||
|
ret = MBEDTLS_ERR_ECP_RANDOM_FAILED;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( secret,
|
||||||
|
secret_bytes, secret_len ) );
|
||||||
|
|
||||||
|
ret = mbedtls_hmac_drbg_seed_buf( ctx, md_info, secret_bytes, secret_len );
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
mbedtls_platform_zeroize( secret_bytes, secret_len );
|
||||||
|
|
||||||
|
return( ret );
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(MBEDTLS_CTR_DRBG_C)
|
||||||
|
|
||||||
|
/* DRBG context type */
|
||||||
|
typedef mbedtls_ctr_drbg_context ecp_drbg_context;
|
||||||
|
|
||||||
|
/* DRBG context init */
|
||||||
|
static inline void ecp_drbg_init( ecp_drbg_context *ctx )
|
||||||
|
{
|
||||||
|
mbedtls_ctr_drbg_init( ctx );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* DRBG context free */
|
||||||
|
static inline void ecp_drbg_free( ecp_drbg_context *ctx )
|
||||||
|
{
|
||||||
|
mbedtls_ctr_drbg_free( ctx );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* DRBG function */
|
||||||
|
static inline int ecp_drbg_random( void *p_rng,
|
||||||
|
unsigned char *output, size_t output_len )
|
||||||
|
{
|
||||||
|
return( mbedtls_ctr_drbg_random( p_rng, output, output_len ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since CTR_DRBG doesn't have a seed_buf() function the way HMAC_DRBG does,
|
||||||
|
* we need to pass an entropy function when seeding. So we use a dummy
|
||||||
|
* function for that, and pass the actual entropy as customisation string.
|
||||||
|
* (During seeding of CTR_DRBG the entropy input and customisation string are
|
||||||
|
* concatenated before being used to update the secret state.)
|
||||||
|
*/
|
||||||
|
static int ecp_ctr_drbg_null_entropy(void *ctx, unsigned char *out, size_t len)
|
||||||
|
{
|
||||||
|
(void) ctx;
|
||||||
|
memset( out, 0, len );
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* DRBG context seeding */
|
||||||
|
static int ecp_drbg_seed( ecp_drbg_context *ctx,
|
||||||
|
const mbedtls_mpi *secret, size_t secret_len )
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
unsigned char secret_bytes[MBEDTLS_ECP_MAX_BYTES];
|
||||||
|
|
||||||
|
if( secret_len > MBEDTLS_ECP_MAX_BYTES )
|
||||||
|
{
|
||||||
|
ret = MBEDTLS_ERR_ECP_RANDOM_FAILED;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( secret,
|
||||||
|
secret_bytes, secret_len ) );
|
||||||
|
|
||||||
|
ret = mbedtls_ctr_drbg_seed( ctx, ecp_ctr_drbg_null_entropy, NULL,
|
||||||
|
secret_bytes, secret_len );
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
mbedtls_platform_zeroize( secret_bytes, secret_len );
|
||||||
|
|
||||||
|
return( ret );
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "Invalid configuration detected. Include check_config.h to ensure that the configuration is valid."
|
||||||
|
#endif /* DRBG modules */
|
||||||
|
#endif /* MBEDTLS_ECP_NO_INTERNAL_RNG */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
/*
|
/*
|
||||||
* Maximum number of "basic operations" to be done in a row.
|
* Maximum number of "basic operations" to be done in a row.
|
||||||
@ -165,6 +313,10 @@ struct mbedtls_ecp_restart_mul
|
|||||||
ecp_rsm_comb_core, /* ecp_mul_comb_core() */
|
ecp_rsm_comb_core, /* ecp_mul_comb_core() */
|
||||||
ecp_rsm_final_norm, /* do the final normalization */
|
ecp_rsm_final_norm, /* do the final normalization */
|
||||||
} state;
|
} state;
|
||||||
|
#if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
ecp_drbg_context drbg_ctx;
|
||||||
|
unsigned char drbg_seeded;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -177,6 +329,10 @@ static void ecp_restart_rsm_init( mbedtls_ecp_restart_mul_ctx *ctx )
|
|||||||
ctx->T = NULL;
|
ctx->T = NULL;
|
||||||
ctx->T_size = 0;
|
ctx->T_size = 0;
|
||||||
ctx->state = ecp_rsm_init;
|
ctx->state = ecp_rsm_init;
|
||||||
|
#if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
ecp_drbg_init( &ctx->drbg_ctx );
|
||||||
|
ctx->drbg_seeded = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -198,6 +354,10 @@ static void ecp_restart_rsm_free( mbedtls_ecp_restart_mul_ctx *ctx )
|
|||||||
mbedtls_free( ctx->T );
|
mbedtls_free( ctx->T );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
ecp_drbg_free( &ctx->drbg_ctx );
|
||||||
|
#endif
|
||||||
|
|
||||||
ecp_restart_rsm_init( ctx );
|
ecp_restart_rsm_init( ctx );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1897,7 +2057,9 @@ static int ecp_mul_comb_core( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R
|
|||||||
i = d;
|
i = d;
|
||||||
MBEDTLS_MPI_CHK( ecp_select_comb( grp, R, T, T_size, x[i] ) );
|
MBEDTLS_MPI_CHK( ecp_select_comb( grp, R, T, T_size, x[i] ) );
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &R->Z, 1 ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &R->Z, 1 ) );
|
||||||
|
#if defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
if( f_rng != 0 )
|
if( f_rng != 0 )
|
||||||
|
#endif
|
||||||
MBEDTLS_MPI_CHK( ecp_randomize_jac( grp, R, f_rng, p_rng ) );
|
MBEDTLS_MPI_CHK( ecp_randomize_jac( grp, R, f_rng, p_rng ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2018,6 +2180,7 @@ static int ecp_mul_comb_after_precomp( const mbedtls_ecp_group *grp,
|
|||||||
rs_ctx->rsm->state = ecp_rsm_final_norm;
|
rs_ctx->rsm->state = ecp_rsm_final_norm;
|
||||||
|
|
||||||
final_norm:
|
final_norm:
|
||||||
|
MBEDTLS_ECP_BUDGET( MBEDTLS_ECP_OPS_INV );
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* Knowledge of the jacobian coordinates may leak the last few bits of the
|
* Knowledge of the jacobian coordinates may leak the last few bits of the
|
||||||
@ -2030,10 +2193,11 @@ final_norm:
|
|||||||
*
|
*
|
||||||
* Avoid the leak by randomizing coordinates before we normalize them.
|
* Avoid the leak by randomizing coordinates before we normalize them.
|
||||||
*/
|
*/
|
||||||
|
#if defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
if( f_rng != 0 )
|
if( f_rng != 0 )
|
||||||
|
#endif
|
||||||
MBEDTLS_MPI_CHK( ecp_randomize_jac( grp, RR, f_rng, p_rng ) );
|
MBEDTLS_MPI_CHK( ecp_randomize_jac( grp, RR, f_rng, p_rng ) );
|
||||||
|
|
||||||
MBEDTLS_ECP_BUDGET( MBEDTLS_ECP_OPS_INV );
|
|
||||||
MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, RR ) );
|
MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, RR ) );
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
@ -2104,11 +2268,44 @@ static int ecp_mul_comb( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
|||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
unsigned char w, p_eq_g, i;
|
unsigned char w, p_eq_g, i;
|
||||||
size_t d;
|
size_t d;
|
||||||
unsigned char T_size, T_ok;
|
unsigned char T_size = 0, T_ok = 0;
|
||||||
mbedtls_ecp_point *T;
|
mbedtls_ecp_point *T = NULL;
|
||||||
|
#if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
ecp_drbg_context drbg_ctx;
|
||||||
|
|
||||||
|
ecp_drbg_init( &drbg_ctx );
|
||||||
|
#endif
|
||||||
|
|
||||||
ECP_RS_ENTER( rsm );
|
ECP_RS_ENTER( rsm );
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
if( f_rng == NULL )
|
||||||
|
{
|
||||||
|
/* Adjust pointers */
|
||||||
|
f_rng = &ecp_drbg_random;
|
||||||
|
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
|
if( rs_ctx != NULL && rs_ctx->rsm != NULL )
|
||||||
|
p_rng = &rs_ctx->rsm->drbg_ctx;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
p_rng = &drbg_ctx;
|
||||||
|
|
||||||
|
/* Initialize internal DRBG if necessary */
|
||||||
|
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
|
if( rs_ctx == NULL || rs_ctx->rsm == NULL ||
|
||||||
|
rs_ctx->rsm->drbg_seeded == 0 )
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
const size_t m_len = ( grp->nbits + 7 ) / 8;
|
||||||
|
MBEDTLS_MPI_CHK( ecp_drbg_seed( p_rng, m, m_len ) );
|
||||||
|
}
|
||||||
|
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
|
if( rs_ctx != NULL && rs_ctx->rsm != NULL )
|
||||||
|
rs_ctx->rsm->drbg_seeded = 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif /* !MBEDTLS_ECP_NO_INTERNAL_RNG */
|
||||||
|
|
||||||
/* Is P the base point ? */
|
/* Is P the base point ? */
|
||||||
#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1
|
#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1
|
||||||
p_eq_g = ( mbedtls_mpi_cmp_mpi( &P->Y, &grp->G.Y ) == 0 &&
|
p_eq_g = ( mbedtls_mpi_cmp_mpi( &P->Y, &grp->G.Y ) == 0 &&
|
||||||
@ -2180,6 +2377,10 @@ static int ecp_mul_comb( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
ecp_drbg_free( &drbg_ctx );
|
||||||
|
#endif
|
||||||
|
|
||||||
/* does T belong to the group? */
|
/* does T belong to the group? */
|
||||||
if( T == grp->T )
|
if( T == grp->T )
|
||||||
T = NULL;
|
T = NULL;
|
||||||
@ -2370,9 +2571,23 @@ static int ecp_mul_mxz( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
|||||||
unsigned char b;
|
unsigned char b;
|
||||||
mbedtls_ecp_point RP;
|
mbedtls_ecp_point RP;
|
||||||
mbedtls_mpi PX;
|
mbedtls_mpi PX;
|
||||||
|
#if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
ecp_drbg_context drbg_ctx;
|
||||||
|
|
||||||
|
ecp_drbg_init( &drbg_ctx );
|
||||||
|
#endif
|
||||||
mbedtls_ecp_point_init( &RP ); mbedtls_mpi_init( &PX );
|
mbedtls_ecp_point_init( &RP ); mbedtls_mpi_init( &PX );
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
if( f_rng == NULL )
|
||||||
|
{
|
||||||
|
const size_t m_len = ( grp->nbits + 7 ) / 8;
|
||||||
|
MBEDTLS_MPI_CHK( ecp_drbg_seed( &drbg_ctx, m, m_len ) );
|
||||||
|
f_rng = &ecp_drbg_random;
|
||||||
|
p_rng = &drbg_ctx;
|
||||||
|
}
|
||||||
|
#endif /* !MBEDTLS_ECP_NO_INTERNAL_RNG */
|
||||||
|
|
||||||
/* Save PX and read from P before writing to R, in case P == R */
|
/* Save PX and read from P before writing to R, in case P == R */
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &PX, &P->X ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &PX, &P->X ) );
|
||||||
MBEDTLS_MPI_CHK( mbedtls_ecp_copy( &RP, P ) );
|
MBEDTLS_MPI_CHK( mbedtls_ecp_copy( &RP, P ) );
|
||||||
@ -2386,7 +2601,9 @@ static int ecp_mul_mxz( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
|||||||
MOD_ADD( RP.X );
|
MOD_ADD( RP.X );
|
||||||
|
|
||||||
/* Randomize coordinates of the starting point */
|
/* Randomize coordinates of the starting point */
|
||||||
|
#if defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
if( f_rng != NULL )
|
if( f_rng != NULL )
|
||||||
|
#endif
|
||||||
MBEDTLS_MPI_CHK( ecp_randomize_mxz( grp, &RP, f_rng, p_rng ) );
|
MBEDTLS_MPI_CHK( ecp_randomize_mxz( grp, &RP, f_rng, p_rng ) );
|
||||||
|
|
||||||
/* Loop invariant: R = result so far, RP = R + P */
|
/* Loop invariant: R = result so far, RP = R + P */
|
||||||
@ -2419,12 +2636,18 @@ static int ecp_mul_mxz( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
|||||||
*
|
*
|
||||||
* Avoid the leak by randomizing coordinates before we normalize them.
|
* Avoid the leak by randomizing coordinates before we normalize them.
|
||||||
*/
|
*/
|
||||||
|
#if defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
if( f_rng != NULL )
|
if( f_rng != NULL )
|
||||||
|
#endif
|
||||||
MBEDTLS_MPI_CHK( ecp_randomize_mxz( grp, R, f_rng, p_rng ) );
|
MBEDTLS_MPI_CHK( ecp_randomize_mxz( grp, R, f_rng, p_rng ) );
|
||||||
|
|
||||||
MBEDTLS_MPI_CHK( ecp_normalize_mxz( grp, R ) );
|
MBEDTLS_MPI_CHK( ecp_normalize_mxz( grp, R ) );
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
#if !defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
ecp_drbg_free( &drbg_ctx );
|
||||||
|
#endif
|
||||||
|
|
||||||
mbedtls_ecp_point_free( &RP ); mbedtls_mpi_free( &PX );
|
mbedtls_ecp_point_free( &RP ); mbedtls_mpi_free( &PX );
|
||||||
|
|
||||||
return( ret );
|
return( ret );
|
||||||
|
@ -1578,6 +1578,8 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl,
|
|||||||
* linking an extra division function in some builds).
|
* linking an extra division function in some builds).
|
||||||
*/
|
*/
|
||||||
size_t j, extra_run = 0;
|
size_t j, extra_run = 0;
|
||||||
|
/* This size is enough to server either as input to
|
||||||
|
* md_process() or as output to md_finish() */
|
||||||
unsigned char tmp[MBEDTLS_MD_MAX_BLOCK_SIZE];
|
unsigned char tmp[MBEDTLS_MD_MAX_BLOCK_SIZE];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1633,10 +1635,15 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl,
|
|||||||
ssl_read_memory( data + rec->data_len, padlen );
|
ssl_read_memory( data + rec->data_len, padlen );
|
||||||
mbedtls_md_hmac_finish( &transform->md_ctx_dec, mac_expect );
|
mbedtls_md_hmac_finish( &transform->md_ctx_dec, mac_expect );
|
||||||
|
|
||||||
/* Call mbedtls_md_process at least once due to cache attacks
|
/* Dummy calls to compression function.
|
||||||
* that observe whether md_process() was called of not */
|
* Call mbedtls_md_process at least once due to cache attacks
|
||||||
|
* that observe whether md_process() was called of not.
|
||||||
|
* Respect the usual start-(process|update)-finish sequence for
|
||||||
|
* the sake of hardware accelerators that might require it. */
|
||||||
|
mbedtls_md_starts( &transform->md_ctx_dec );
|
||||||
for( j = 0; j < extra_run + 1; j++ )
|
for( j = 0; j < extra_run + 1; j++ )
|
||||||
mbedtls_md_process( &transform->md_ctx_dec, tmp );
|
mbedtls_md_process( &transform->md_ctx_dec, tmp );
|
||||||
|
mbedtls_md_finish( &transform->md_ctx_dec, tmp );
|
||||||
|
|
||||||
mbedtls_md_hmac_reset( &transform->md_ctx_dec );
|
mbedtls_md_hmac_reset( &transform->md_ctx_dec );
|
||||||
|
|
||||||
|
@ -354,6 +354,9 @@ static const char * const features[] = {
|
|||||||
#if defined(MBEDTLS_ECP_NIST_OPTIM)
|
#if defined(MBEDTLS_ECP_NIST_OPTIM)
|
||||||
"MBEDTLS_ECP_NIST_OPTIM",
|
"MBEDTLS_ECP_NIST_OPTIM",
|
||||||
#endif /* MBEDTLS_ECP_NIST_OPTIM */
|
#endif /* MBEDTLS_ECP_NIST_OPTIM */
|
||||||
|
#if defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
"MBEDTLS_ECP_NO_INTERNAL_RNG",
|
||||||
|
#endif /* MBEDTLS_ECP_NO_INTERNAL_RNG */
|
||||||
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
"MBEDTLS_ECP_RESTARTABLE",
|
"MBEDTLS_ECP_RESTARTABLE",
|
||||||
#endif /* MBEDTLS_ECP_RESTARTABLE */
|
#endif /* MBEDTLS_ECP_RESTARTABLE */
|
||||||
|
@ -986,6 +986,14 @@ int query_config( const char *config )
|
|||||||
}
|
}
|
||||||
#endif /* MBEDTLS_ECP_NIST_OPTIM */
|
#endif /* MBEDTLS_ECP_NIST_OPTIM */
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_ECP_NO_INTERNAL_RNG)
|
||||||
|
if( strcmp( "MBEDTLS_ECP_NO_INTERNAL_RNG", config ) == 0 )
|
||||||
|
{
|
||||||
|
MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_NO_INTERNAL_RNG );
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_ECP_NO_INTERNAL_RNG */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
if( strcmp( "MBEDTLS_ECP_RESTARTABLE", config ) == 0 )
|
if( strcmp( "MBEDTLS_ECP_RESTARTABLE", config ) == 0 )
|
||||||
{
|
{
|
||||||
|
@ -173,6 +173,7 @@ EXCLUDE_FROM_FULL = frozenset([
|
|||||||
'MBEDTLS_DEPRECATED_REMOVED', # conflicts with deprecated options
|
'MBEDTLS_DEPRECATED_REMOVED', # conflicts with deprecated options
|
||||||
'MBEDTLS_DEPRECATED_WARNING', # conflicts with deprecated options
|
'MBEDTLS_DEPRECATED_WARNING', # conflicts with deprecated options
|
||||||
'MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED', # influences the use of ECDH in TLS
|
'MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED', # influences the use of ECDH in TLS
|
||||||
|
'MBEDTLS_ECP_NO_INTERNAL_RNG', # removes a feature
|
||||||
'MBEDTLS_ECP_RESTARTABLE', # incompatible with USE_PSA_CRYPTO
|
'MBEDTLS_ECP_RESTARTABLE', # incompatible with USE_PSA_CRYPTO
|
||||||
'MBEDTLS_ENTROPY_FORCE_SHA256', # interacts with CTR_DRBG_128_BIT_KEY
|
'MBEDTLS_ENTROPY_FORCE_SHA256', # interacts with CTR_DRBG_128_BIT_KEY
|
||||||
'MBEDTLS_HAVE_SSE2', # hardware dependency
|
'MBEDTLS_HAVE_SSE2', # hardware dependency
|
||||||
|
@ -929,6 +929,43 @@ component_test_no_hmac_drbg () {
|
|||||||
# so there's little value in running those lengthy tests here.
|
# so there's little value in running those lengthy tests here.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component_test_ecp_no_internal_rng () {
|
||||||
|
msg "build: Default plus ECP_NO_INTERNAL_RNG minus DRBG modules"
|
||||||
|
scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
|
||||||
|
scripts/config.py unset MBEDTLS_CTR_DRBG_C
|
||||||
|
scripts/config.py unset MBEDTLS_HMAC_DRBG_C
|
||||||
|
scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
|
||||||
|
scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires a DRBG
|
||||||
|
scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
|
||||||
|
|
||||||
|
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||||
|
make
|
||||||
|
|
||||||
|
msg "test: ECP_NO_INTERNAL_RNG, no DRBG module"
|
||||||
|
make test
|
||||||
|
|
||||||
|
# no SSL tests as they all depend on having a DRBG
|
||||||
|
}
|
||||||
|
|
||||||
|
component_test_ecp_restartable_no_internal_rng () {
|
||||||
|
msg "build: Default plus ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG"
|
||||||
|
scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
|
||||||
|
scripts/config.py set MBEDTLS_ECP_RESTARTABLE
|
||||||
|
scripts/config.py unset MBEDTLS_CTR_DRBG_C
|
||||||
|
scripts/config.py unset MBEDTLS_HMAC_DRBG_C
|
||||||
|
scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
|
||||||
|
scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires CTR_DRBG
|
||||||
|
scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
|
||||||
|
|
||||||
|
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||||
|
make
|
||||||
|
|
||||||
|
msg "test: ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG module"
|
||||||
|
make test
|
||||||
|
|
||||||
|
# no SSL tests as they all depend on having a DRBG
|
||||||
|
}
|
||||||
|
|
||||||
component_test_new_ecdh_context () {
|
component_test_new_ecdh_context () {
|
||||||
msg "build: new ECDH context (ASan build)" # ~ 6 min
|
msg "build: new ECDH context (ASan build)" # ~ 6 min
|
||||||
scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
|
scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
Check compiletime library version
|
Check compiletime library version
|
||||||
check_compiletime_version:"2.22.0"
|
check_compiletime_version:"2.23.0"
|
||||||
|
|
||||||
Check runtime library version
|
Check runtime library version
|
||||||
check_runtime_version:"2.22.0"
|
check_runtime_version:"2.23.0"
|
||||||
|
|
||||||
Check for MBEDTLS_VERSION_C
|
Check for MBEDTLS_VERSION_C
|
||||||
check_feature:"MBEDTLS_VERSION_C":0
|
check_feature:"MBEDTLS_VERSION_C":0
|
||||||
|
Loading…
Reference in New Issue
Block a user