Merge pull request #957 from paul-elliott-arm/mbedtls-3.2.0rc0-pr
Mbedtls 3.2.0rc0 PR
This commit is contained in:
commit
3aef7670b7
@ -12,11 +12,6 @@ At any point in time, we have a number of maintained branches, currently consist
|
||||
- One or more long-time support (LTS) branches: these only get bug fixes and
|
||||
security fixes. Currently, the only supported LTS branch is:
|
||||
[`mbedtls-2.28`](https://github.com/Mbed-TLS/mbedtls/tree/mbedtls-2.28).
|
||||
- For a short time we also have the previous LTS, which has recently ended its
|
||||
support period,
|
||||
[`mbedtls-2.16`](https://github.com/Mbed-TLS/mbedtls/tree/mbedtls-2.16).
|
||||
This branch will move into the `archive` namespace around the time of
|
||||
the next release.
|
||||
|
||||
We retain a number of historical branches, whose names are prefixed by `archive/`,
|
||||
such as [`archive/mbedtls-2.7`](https://github.com/Mbed-TLS/mbedtls/tree/archive/mbedtls-2.7).
|
||||
|
@ -59,7 +59,7 @@ option(MBEDTLS_FATAL_WARNINGS "Compiler warnings treated as errors" ON)
|
||||
if(CMAKE_HOST_WIN32)
|
||||
option(GEN_FILES "Generate the auto-generated files as needed" OFF)
|
||||
else()
|
||||
option(GEN_FILES "Generate the auto-generated files as needed" ON)
|
||||
option(GEN_FILES "Generate the auto-generated files as needed" OFF)
|
||||
endif()
|
||||
|
||||
option(DISABLE_PACKAGE_CONFIG_AND_INSTALL "Disable package configuration, target export and installation" ${MBEDTLS_AS_SUBPROJECT})
|
||||
@ -348,7 +348,7 @@ if(NOT DISABLE_PACKAGE_CONFIG_AND_INSTALL)
|
||||
write_basic_package_version_file(
|
||||
"cmake/MbedTLSConfigVersion.cmake"
|
||||
COMPATIBILITY SameMajorVersion
|
||||
VERSION 3.1.0)
|
||||
VERSION 3.2.0)
|
||||
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/MbedTLSConfig.cmake"
|
||||
|
272
ChangeLog
272
ChangeLog
@ -1,4 +1,274 @@
|
||||
mbed TLS ChangeLog (Sorted per branch, date)
|
||||
Mbed TLS ChangeLog (Sorted per branch, date)
|
||||
|
||||
= Mbed TLS 3.2.0 branch released 2022-07-11
|
||||
|
||||
Default behavior changes
|
||||
* mbedtls_cipher_set_iv will now fail with ChaCha20 and ChaCha20+Poly1305
|
||||
for IV lengths other than 12. The library was silently overwriting this
|
||||
length with 12, but did not inform the caller about it. Fixes #4301.
|
||||
|
||||
Requirement changes
|
||||
* The library will no longer compile out of the box on a platform without
|
||||
setbuf(). If your platform does not have setbuf(), you can configure an
|
||||
alternative function by enabling MBEDTLS_PLATFORM_SETBUF_ALT or
|
||||
MBEDTLS_PLATFORM_SETBUF_MACRO.
|
||||
|
||||
New deprecations
|
||||
* Deprecate mbedtls_ssl_conf_max_version() and
|
||||
mbedtls_ssl_conf_min_version() in favor of
|
||||
mbedtls_ssl_conf_max_tls_version() and
|
||||
mbedtls_ssl_conf_min_tls_version().
|
||||
* Deprecate mbedtls_cipher_setup_psa(). Use psa_aead_xxx() or
|
||||
psa_cipher_xxx() directly instead.
|
||||
* Secure element drivers enabled by MBEDTLS_PSA_CRYPTO_SE_C are deprecated.
|
||||
This was intended as an experimental feature, but had not been explicitly
|
||||
documented as such. Use opaque drivers with the interface enabled by
|
||||
MBEDTLS_PSA_CRYPTO_DRIVERS instead.
|
||||
* Deprecate mbedtls_ssl_conf_sig_hashes() in favor of the more generic
|
||||
mbedtls_ssl_conf_sig_algs(). Signature algorithms for the TLS 1.2 and
|
||||
TLS 1.3 handshake should now be configured with
|
||||
mbedtls_ssl_conf_sig_algs().
|
||||
|
||||
Features
|
||||
* Add accessor to obtain ciphersuite id from ssl context.
|
||||
* Add accessors to get members from ciphersuite info.
|
||||
* Add mbedtls_ssl_ticket_rotate() for external ticket rotation.
|
||||
* Add accessor to get the raw buffer pointer from a PEM context.
|
||||
* The structures mbedtls_ssl_config and mbedtls_ssl_context now store
|
||||
a piece of user data which is reserved for the application. The user
|
||||
data can be either a pointer or an integer.
|
||||
* Add an accessor function to get the configuration associated with
|
||||
an SSL context.
|
||||
* Add a function to access the protocol version from an SSL context in a
|
||||
form that's easy to compare. Fixes #5407.
|
||||
* Add function mbedtls_md_info_from_ctx() to recall the message digest
|
||||
information that was used to set up a message digest context.
|
||||
* Add ALPN support in TLS 1.3 clients.
|
||||
* Add server certificate selection callback near end of Client Hello.
|
||||
Register callback with mbedtls_ssl_conf_cert_cb().
|
||||
* Provide mechanism to reset handshake cert list by calling
|
||||
mbedtls_ssl_set_hs_own_cert() with NULL value for own_cert param.
|
||||
* Add accessor mbedtls_ssl_get_hs_sni() to retrieve SNI from within
|
||||
cert callback (mbedtls_ssl_conf_cert_cb()) during handshake.
|
||||
* The X.509 module now uses PSA hash acceleration if present.
|
||||
* Add support for psa crypto key derivation for elliptic curve
|
||||
keys. Fixes #3260.
|
||||
* Add function mbedtls_timing_get_final_delay() to access the private
|
||||
final delay field in an mbedtls_timing_delay_context, as requested in
|
||||
#5183.
|
||||
* Add mbedtls_pk_sign_ext() which allows generating RSA-PSS signatures when
|
||||
PSA Crypto is enabled.
|
||||
* Add function mbedtls_ecp_export() to export ECP key pair parameters.
|
||||
Fixes #4838.
|
||||
* Add function mbedtls_ssl_is_handshake_over() to enable querying if the SSL
|
||||
Handshake has completed or not, and thus whether to continue calling
|
||||
mbedtls_ssl_handshake_step(), requested in #4383.
|
||||
* Add the function mbedtls_ssl_get_own_cid() to access our own connection id
|
||||
within mbedtls_ssl_context, as requested in #5184.
|
||||
* Introduce mbedtls_ssl_hs_cb_t typedef for use with
|
||||
mbedtls_ssl_conf_cert_cb() and perhaps future callbacks
|
||||
during TLS handshake.
|
||||
* Add functions mbedtls_ssl_conf_max_tls_version() and
|
||||
mbedtls_ssl_conf_min_tls_version() that use a single value to specify
|
||||
the protocol version.
|
||||
* Extend the existing PSA_ALG_TLS12_PSK_TO_MS() algorithm to support
|
||||
mixed-PSK. Add an optional input PSA_KEY_DERIVATION_INPUT_OTHER_SECRET
|
||||
holding the other secret.
|
||||
* When MBEDTLS_PSA_CRYPTO_CONFIG is enabled, you may list the PSA crypto
|
||||
feature requirements in the file named by the new macro
|
||||
MBEDTLS_PSA_CRYPTO_CONFIG_FILE instead of the default psa/crypto_config.h.
|
||||
Furthermore you may name an additional file to include after the main
|
||||
file with the macro MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE.
|
||||
* Add the function mbedtls_x509_crt_has_ext_type() to access the ext types
|
||||
field within mbedtls_x509_crt context, as requested in #5585.
|
||||
* Add HKDF-Expand and HKDF-Extract as separate algorithms in the PSA API.
|
||||
* Add support for the ARMv8 SHA-2 acceleration instructions when building
|
||||
for Aarch64.
|
||||
* Add support for authentication of TLS 1.3 clients by TLS 1.3 servers.
|
||||
* Add support for server HelloRetryRequest message. The TLS 1.3 client is
|
||||
now capable of negotiating another shared secret if the one sent in its
|
||||
first ClientHello was not suitable to the server.
|
||||
* Add support for client-side TLS version negotiation. If both TLS 1.2 and
|
||||
TLS 1.3 protocols are enabled in the build of Mbed TLS, the TLS client now
|
||||
negotiates TLS 1.3 or TLS 1.2 with TLS servers.
|
||||
* Enable building of Mbed TLS with TLS 1.3 protocol support but without TLS
|
||||
1.2 protocol support.
|
||||
* Mbed TLS provides an implementation of a TLS 1.3 server (ephemeral key
|
||||
establishment only). See docs/architecture/tls13-support.md for a
|
||||
description of the support. The MBEDTLS_SSL_PROTO_TLS1_3 and
|
||||
MBEDTLS_SSL_SRV_C configuration options control this.
|
||||
* Add accessors to configure DN hints for certificate request:
|
||||
mbedtls_ssl_conf_dn_hints() and mbedtls_ssl_set_hs_dn_hints()
|
||||
* The configuration option MBEDTLS_USE_PSA_CRYPTO, which previously
|
||||
affected only a limited subset of crypto operations in TLS, X.509 and PK,
|
||||
now causes most of them to be done using PSA Crypto; see
|
||||
docs/use-psa-crypto.md for the list of exceptions.
|
||||
* The function mbedtls_pk_setup_opaque() now supports RSA key pairs as well.
|
||||
Opaque keys can now be used everywhere a private key is expected in the
|
||||
TLS and X.509 modules.
|
||||
* Opaque pre-shared keys for TLS, provisioned with
|
||||
mbedtls_ssl_conf_psk_opaque() or mbedtls_ssl_set_hs_psk_opaque(), which
|
||||
previously only worked for "pure" PSK key exchange, now can also be used
|
||||
for the "mixed" PSK key exchanges as well: ECDHE-PSK, DHE-PSK, RSA-PSK.
|
||||
* cmake now detects if it is being built as a sub-project, and in that case
|
||||
disables the target export/installation and package configuration.
|
||||
* Make USE_PSA_CRYPTO compatible with KEY_ID_ENCODES_OWNER. Fixes #5259.
|
||||
* Add example programs cipher_aead_demo.c, md_hmac_demo.c, aead_demo.c
|
||||
and hmac_demo.c, which use PSA and the md/cipher interfaces side
|
||||
by side in order to illustrate how the operation is performed in PSA.
|
||||
Addresses #5208.
|
||||
|
||||
Security
|
||||
* Zeroize dynamically-allocated buffers used by the PSA Crypto key storage
|
||||
module before freeing them. These buffers contain secret key material, and
|
||||
could thus potentially leak the key through freed heap.
|
||||
* Fix potential memory leak inside mbedtls_ssl_cache_set() with
|
||||
an invalid session id length.
|
||||
* Add the platform function mbedtls_setbuf() to allow buffering to be
|
||||
disabled on stdio files, to stop secrets loaded from said files being
|
||||
potentially left in memory after file operations. Reported by
|
||||
Glenn Strauss.
|
||||
* Fix a potential heap buffer overread in TLS 1.2 server-side when
|
||||
MBEDTLS_USE_PSA_CRYPTO is enabled, an opaque key (created with
|
||||
mbedtls_pk_setup_opaque()) is provisioned, and a static ECDH ciphersuite
|
||||
is selected. This may result in an application crash or potentially an
|
||||
information leak.
|
||||
* Fix a buffer overread in DTLS ClientHello parsing in servers with
|
||||
MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE enabled. An unauthenticated client
|
||||
or a man-in-the-middle could cause a DTLS server to read up to 255 bytes
|
||||
after the end of the SSL input buffer. The buffer overread only happens
|
||||
when MBEDTLS_SSL_IN_CONTENT_LEN is less than a threshold that depends on
|
||||
the exact configuration: 258 bytes if using mbedtls_ssl_cookie_check(),
|
||||
and possibly up to 571 bytes with a custom cookie check function.
|
||||
Reported by the Cybeats PSI Team.
|
||||
* Fix a buffer overread in TLS 1.3 Certificate parsing. An unauthenticated
|
||||
client or server could cause an MbedTLS server or client to overread up
|
||||
to 64 kBytes of data and potentially overread the input buffer by that
|
||||
amount minus the size of the input buffer. As overread data undergoes
|
||||
various checks, the likelihood of reaching the boundary of the input
|
||||
buffer is rather small but increases as its size
|
||||
MBEDTLS_SSL_IN_CONTENT_LEN decreases.
|
||||
* Fix check of certificate key usage in TLS 1.3. The usage of the public key
|
||||
provided by a client or server certificate for authentication was not
|
||||
checked properly when validating the certificate. This could cause a
|
||||
client or server to be able to authenticate itself through a certificate
|
||||
to an Mbed TLS TLS 1.3 server or client while it does not own a proper
|
||||
certificate to do so.
|
||||
|
||||
Bugfix
|
||||
* Declare or use PSA_WANT_ALG_CCM_STAR_NO_TAG following the general
|
||||
pattern for PSA_WANT_xxx symbols. Previously you had to specify
|
||||
PSA_WANT_ALG_CCM for PSA_ALG_CCM_STAR_NO_TAG.
|
||||
* Fix a memory leak if mbedtls_ssl_config_defaults() is called twice.
|
||||
* Fixed swap of client and server random bytes when exporting them alongside
|
||||
TLS 1.3 handshake and application traffic secret.
|
||||
* Fix several bugs (warnings, compiler and linker errors, test failures)
|
||||
in reduced configurations when MBEDTLS_USE_PSA_CRYPTO is enabled.
|
||||
* Fix a bug in (D)TLS curve negotiation: when MBEDTLS_USE_PSA_CRYPTO was
|
||||
enabled and an ECDHE-ECDSA or ECDHE-RSA key exchange was used, the
|
||||
client would fail to check that the curve selected by the server for
|
||||
ECDHE was indeed one that was offered. As a result, the client would
|
||||
accept any curve that it supported, even if that curve was not allowed
|
||||
according to its configuration. Fixes #5291.
|
||||
* The TLS 1.3 implementation is now compatible with the
|
||||
MBEDTLS_USE_PSA_CRYPTO configuration option.
|
||||
* Fix unit tests that used 0 as the file UID. This failed on some
|
||||
implementations of PSA ITS. Fixes #3838.
|
||||
* Fix mbedtls_ssl_get_version() not reporting TLSv1.3. Fixes #5406.
|
||||
* Fix API violation in mbedtls_md_process() test by adding a call to
|
||||
mbedtls_md_starts(). Fixes #2227.
|
||||
* Fix compile errors when MBEDTLS_HAVE_TIME is not defined. Add tests
|
||||
to catch bad uses of time.h.
|
||||
* Fix a race condition in out-of-source builds with CMake when generated data
|
||||
files are already present. Fixes #5374.
|
||||
* Fix the library search path when building a shared library with CMake
|
||||
on Windows.
|
||||
* Fix bug in the alert sending function mbedtls_ssl_send_alert_message()
|
||||
potentially leading to corrupted alert messages being sent in case
|
||||
the function needs to be re-called after initially returning
|
||||
MBEDTLS_SSL_WANT_WRITE. Fixes #1916.
|
||||
* In configurations with MBEDTLS_SSL_DTLS_CONNECTION_ID enabled but not
|
||||
MBEDTLS_DEBUG_C, DTLS handshakes using CID would crash due to a null
|
||||
pointer dereference. Fix this. Fixes #3998.
|
||||
The fix was released, but not announced, in Mbed TLS 3.1.0.
|
||||
* Fix incorrect documentation of mbedtls_x509_crt_profile. The previous
|
||||
documentation stated that the `allowed_pks` field applies to signatures
|
||||
only, but in fact it does apply to the public key type of the end entity
|
||||
certificate, too. Fixes #1992.
|
||||
* Fix undefined behavior in mbedtls_asn1_find_named_data(), where val is
|
||||
not NULL and val_len is zero.
|
||||
* Fix compilation error with mingw32. Fixed by Cameron Cawley in #4211.
|
||||
* Fix compilation error when using C++ Builder on Windows. Reported by
|
||||
Miroslav Mastny in #4015.
|
||||
* psa_raw_key_agreement() now returns PSA_ERROR_BUFFER_TOO_SMALL when
|
||||
applicable. Fixes #5735.
|
||||
* Fix a bug in the x25519 example program where the removal of
|
||||
MBEDTLS_ECDH_LEGACY_CONTEXT caused the program not to run. Fixes #4901 and
|
||||
#3191.
|
||||
* Fix a TLS 1.3 handshake failure when the peer Finished message has not
|
||||
been received yet when we first try to fetch it.
|
||||
* Encode X.509 dates before 1/1/2000 as UTCTime rather than
|
||||
GeneralizedTime. Fixes #5465.
|
||||
* Add mbedtls_x509_dn_get_next function to return the next relative DN in
|
||||
an X509 name, to allow walking the name list. Fixes #5431.
|
||||
* Fix order value of curve x448.
|
||||
* Fix string representation of DNs when outputting values containing commas
|
||||
and other special characters, conforming to RFC 1779. Fixes #769.
|
||||
* Silence a warning from GCC 12 in the selftest program. Fixes #5974.
|
||||
* Fix check_config.h to check that we have MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
|
||||
when MBEDTLS_SSL_PROTO_TLS1_3 is specified, and make this and other
|
||||
dependencies explicit in the documentation. Fixes #5610.
|
||||
* Fix mbedtls_asn1_write_mpi() writing an incorrect encoding of 0.
|
||||
* Fix a TLS 1.3 handshake failure when the first attempt to send the client
|
||||
Finished message on the network cannot be satisfied. Fixes #5499.
|
||||
* Fix resource leaks in mbedtls_pk_parse_public_key() in low
|
||||
memory conditions.
|
||||
* Fix server connection identifier setting for outgoing encrypted records
|
||||
on DTLS 1.2 session resumption. After DTLS 1.2 session resumption with
|
||||
connection identifier, the Mbed TLS client now properly sends the server
|
||||
connection identifier in encrypted record headers. Fix #5872.
|
||||
* Fix a null pointer dereference when performing some operations on zero
|
||||
represented with 0 limbs (specifically mbedtls_mpi_mod_int() dividing
|
||||
by 2, and mbedtls_mpi_write_string() in base 2).
|
||||
* Fix record sizes larger than 16384 being sometimes accepted despite being
|
||||
non-compliant. This could not lead to a buffer overflow. In particular,
|
||||
application data size was already checked correctly.
|
||||
* Fix MBEDTLS_SVC_KEY_ID_GET_KEY_ID() and MBEDTLS_SVC_KEY_ID_GET_OWNER_ID()
|
||||
which have been broken, resulting in compilation errors, since Mbed TLS
|
||||
3.0.
|
||||
* Ensure that TLS 1.2 ciphersuite/certificate and key selection takes into
|
||||
account not just the type of the key (RSA vs EC) but also what it can
|
||||
actually do. Resolves #5831.
|
||||
* Fix CMake windows host detection, especially when cross compiling.
|
||||
* Fix an error in make where the absence of a generated file caused
|
||||
make to break on a clean checkout. Fixes #5340.
|
||||
* Work around an MSVC ARM64 compiler bug causing incorrect behaviour
|
||||
in mbedtls_mpi_exp_mod(). Reported by Tautvydas Žilys in #5467.
|
||||
* Removed the prompt to exit from all windows build programs that was causing
|
||||
issues in CI/CD environments.
|
||||
|
||||
Changes
|
||||
* The file library/psa_crypto_driver_wrappers.c is now generated
|
||||
from a template. In the future, the generation will support
|
||||
driver descriptions. For the time being, to customize this file,
|
||||
see docs/proposed/psa-driver-wrappers-codegen-migration-guide.md
|
||||
* Return PSA_ERROR_INVALID_ARGUMENT if the algorithm passed to one-shot
|
||||
AEAD functions is not an AEAD algorithm. This aligns them with the
|
||||
multipart functions, and the PSA Crypto API 1.1 specification.
|
||||
* In mbedtls_pk_parse_key(), if no password is provided, don't allocate a
|
||||
temporary variable on the heap. Suggested by Sergey Kanatov in #5304.
|
||||
* Assume source files are in UTF-8 when using MSVC with CMake.
|
||||
* Fix runtime library install location when building with CMake and MinGW.
|
||||
DLLs are now installed in the bin directory instead of lib.
|
||||
* cmake: Use GnuInstallDirs to customize install directories
|
||||
Replace custom LIB_INSTALL_DIR variable with standard CMAKE_INSTALL_LIBDIR
|
||||
variable. For backward compatibility, set CMAKE_INSTALL_LIBDIR if
|
||||
LIB_INSTALL_DIR is set.
|
||||
* Add a CMake option that enables static linking of the runtime library
|
||||
in Microsoft Visual C++ compiler. Contributed by Microplankton.
|
||||
* In CMake builds, add aliases for libraries so that the normal MbedTLS::*
|
||||
targets work when MbedTLS is built as a subdirectory. This allows the
|
||||
use of FetchContent, as requested in #5688.
|
||||
|
||||
= mbed TLS 3.1.0 branch released 2021-12-17
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
Changes
|
||||
* The file library/psa_crypto_driver_wrappers.c is now generated
|
||||
from a template. In the future, the generation will support
|
||||
driver descriptions. For the time being, to customize this file,
|
||||
see docs/proposed/psa-driver-wrappers-codegen-migration-guide.md
|
@ -1,2 +0,0 @@
|
||||
Features
|
||||
* The X.509 module now uses PSA hash acceleration if present.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* Fix unit tests that used 0 as the file UID. This failed on some
|
||||
implementations of PSA ITS. Fixes #3838.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* Fix API violation in mbedtls_md_process() test by adding a call to
|
||||
mbedtls_md_starts(). Fixes #2227.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* Add mbedtls_x509_dn_get_next function to return the next relative DN in
|
||||
an X509 name, to allow walking the name list. Fixes #5431.
|
@ -1,4 +0,0 @@
|
||||
Features
|
||||
* Add function mbedtls_timing_get_final_delay() to access the private
|
||||
final delay field in an mbedtls_timing_delay_context, as requested in
|
||||
#5183.
|
@ -1,4 +0,0 @@
|
||||
Features
|
||||
* Add function mbedtls_ssl_is_handshake_over() to enable querying if the SSL
|
||||
Handshake has completed or not, and thus whether to continue calling
|
||||
mbedtls_ssl_handshake_step(), requested in #4383.
|
@ -1,4 +0,0 @@
|
||||
Features
|
||||
* Add the function mbedtls_ssl_get_own_cid() to access our own connection id
|
||||
within mbedtls_ssl_context, as requested in #5184.
|
||||
|
@ -1,5 +0,0 @@
|
||||
Bugfix
|
||||
* Fix bug in the alert sending function mbedtls_ssl_send_alert_message()
|
||||
potentially leading to corrupted alert messages being sent in case
|
||||
the function needs to be re-called after initially returning
|
||||
MBEDTLS_SSL_WANT_WRITE. Fixes #1916.
|
@ -1,2 +0,0 @@
|
||||
Bugfix
|
||||
* Fix mbedtls_asn1_write_mpi() writing an incorrect encoding of 0.
|
@ -1,2 +0,0 @@
|
||||
Bugfix
|
||||
* Fix order value of curve x448.
|
@ -1,4 +0,0 @@
|
||||
Bugfix
|
||||
* Declare or use PSA_WANT_ALG_CCM_STAR_NO_TAG following the general
|
||||
pattern for PSA_WANT_xxx symbols. Previously you had to specify
|
||||
PSA_WANT_ALG_CCM for PSA_ALG_CCM_STAR_NO_TAG.
|
@ -1,4 +0,0 @@
|
||||
Default behavior changes
|
||||
* mbedtls_cipher_set_iv will now fail with ChaCha20 and ChaCha20+Poly1305
|
||||
for IV lengths other than 12. The library was silently overwriting this
|
||||
length with 12, but did not inform the caller about it. Fixes #4301.
|
@ -1,4 +0,0 @@
|
||||
Changes
|
||||
* In CMake builds, add aliases for libraries so that the normal MbedTLS::*
|
||||
targets work when MbedTLS is built as a subdirectory. This allows the
|
||||
use of FetchContent, as requested in #5688.
|
@ -1,3 +0,0 @@
|
||||
Changes
|
||||
* Fix runtime library install location when building with CMake and MinGW.
|
||||
DLLs are now installed in the bin directory instead of lib.
|
@ -1,2 +0,0 @@
|
||||
Changes
|
||||
* Assume source files are in UTF-8 when using MSVC with CMake.
|
@ -1,5 +0,0 @@
|
||||
Changes
|
||||
* cmake: Use GnuInstallDirs to customize install directories
|
||||
Replace custom LIB_INSTALL_DIR variable with standard CMAKE_INSTALL_LIBDIR
|
||||
variable. For backward compatibility, set CMAKE_INSTALL_LIBDIR if
|
||||
LIB_INSTALL_DIR is set.
|
@ -1,3 +0,0 @@
|
||||
New deprecations
|
||||
* Deprecate mbedtls_cipher_setup_psa(). Use psa_aead_xxx() or
|
||||
psa_cipher_xxx() directly instead.
|
@ -1,5 +0,0 @@
|
||||
Bugfix
|
||||
* Fix incorrect documentation of mbedtls_x509_crt_profile. The previous
|
||||
documentation stated that the `allowed_pks` field applies to signatures
|
||||
only, but in fact it does apply to the public key type of the end entity
|
||||
certificate, too. Fixes #1992.
|
@ -1,5 +0,0 @@
|
||||
Bugfix
|
||||
* In configurations with MBEDTLS_SSL_DTLS_CONNECTION_ID enabled but not
|
||||
MBEDTLS_DEBUG_C, DTLS handshakes using CID would crash due to a null
|
||||
pointer dereference. Fix this. Fixes #3998.
|
||||
The fix was released, but not announced, in Mbed TLS 3.1.0.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* Fix string representation of DNs when outputting values containing commas
|
||||
and other special characters, conforming to RFC 1779. Fixes #769.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* Fix a race condition in out-of-source builds with CMake when generated data
|
||||
files are already present. Fixes #5374.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* Encode X.509 dates before 1/1/2000 as UTCTime rather than
|
||||
GeneralizedTime. Fixes #5465.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* Fix undefined behavior in mbedtls_asn1_find_named_data(), where val is
|
||||
not NULL and val_len is zero.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* Fix the library search path when building a shared library with CMake
|
||||
on Windows.
|
@ -1,4 +0,0 @@
|
||||
Bugfix
|
||||
* Fix a bug in the x25519 example program where the removal of
|
||||
MBEDTLS_ECDH_LEGACY_CONTEXT caused the program not to run. Fixes #4901 and
|
||||
#3191.
|
@ -1,6 +0,0 @@
|
||||
Bugfix
|
||||
* Fix resource leaks in mbedtls_pk_parse_public_key() in low
|
||||
memory conditions.
|
||||
Security
|
||||
* Fix potential memory leak inside mbedtls_ssl_cache_set() with
|
||||
an invalid session id length.
|
@ -1,2 +0,0 @@
|
||||
Features
|
||||
* Add HKDF-Expand and HKDF-Extract as separate algorithms in the PSA API.
|
@ -1,3 +0,0 @@
|
||||
Features
|
||||
* Add function mbedtls_ecp_export() to export ECP key pair parameters.
|
||||
Fixes #4838.
|
@ -1,2 +0,0 @@
|
||||
Features
|
||||
* Add accessor to get the raw buffer pointer from a PEM context.
|
@ -1,3 +0,0 @@
|
||||
Features
|
||||
* Add mbedtls_pk_sign_ext() which allows generating RSA-PSS signatures when
|
||||
PSA Crypto is enabled.
|
@ -1,3 +0,0 @@
|
||||
Features
|
||||
* Add support for the ARMv8 SHA-2 acceleration instructions when building
|
||||
for Aarch64.
|
@ -1,7 +0,0 @@
|
||||
Features
|
||||
* Add server certificate selection callback near end of Client Hello.
|
||||
Register callback with mbedtls_ssl_conf_cert_cb().
|
||||
* Provide mechanism to reset handshake cert list by calling
|
||||
mbedtls_ssl_set_hs_own_cert() with NULL value for own_cert param.
|
||||
* Add accessor mbedtls_ssl_get_hs_sni() to retrieve SNI from within
|
||||
cert callback (mbedtls_ssl_conf_cert_cb()) during handshake.
|
@ -1,2 +0,0 @@
|
||||
Bugfix
|
||||
* Fix a memory leak if mbedtls_ssl_config_defaults() is called twice.
|
@ -1,3 +0,0 @@
|
||||
Features
|
||||
* Add accessors to configure DN hints for certificate request:
|
||||
mbedtls_ssl_conf_dn_hints() and mbedtls_ssl_set_hs_dn_hints()
|
@ -1,3 +0,0 @@
|
||||
Features
|
||||
* Add accessor to obtain ciphersuite id from ssl context.
|
||||
* Add accessors to get members from ciphersuite info.
|
@ -1,4 +0,0 @@
|
||||
Features
|
||||
* Introduce mbedtls_ssl_hs_cb_t typedef for use with
|
||||
mbedtls_ssl_conf_cert_cb() and perhaps future callbacks
|
||||
during TLS handshake.
|
@ -1,2 +0,0 @@
|
||||
Features
|
||||
* Add mbedtls_ssl_ticket_rotate() for external ticket rotation.
|
@ -1,2 +0,0 @@
|
||||
Features
|
||||
* Add ALPN support in TLS 1.3 clients.
|
@ -1,10 +0,0 @@
|
||||
New deprecations
|
||||
* Deprecate mbedtls_ssl_conf_max_version() and
|
||||
mbedtls_ssl_conf_min_version() in favor of
|
||||
mbedtls_ssl_conf_max_tls_version() and
|
||||
mbedtls_ssl_conf_min_tls_version().
|
||||
|
||||
Features
|
||||
* Add functions mbedtls_ssl_conf_max_tls_version() and
|
||||
mbedtls_ssl_conf_min_tls_version() that use a single value to specify
|
||||
the protocol version.
|
@ -1,3 +0,0 @@
|
||||
Features
|
||||
* Add function mbedtls_md_info_from_ctx() to recall the message digest
|
||||
information that was used to set up a message digest context.
|
@ -1,4 +0,0 @@
|
||||
Bugfix
|
||||
* Fix compilation error with mingw32. Fixed by Cameron Cawley in #4211.
|
||||
* Fix compilation error when using C++ Builder on Windows. Reported by
|
||||
Miroslav Mastny in #4015.
|
@ -1,3 +0,0 @@
|
||||
Changes
|
||||
* In mbedtls_pk_parse_key(), if no password is provided, don't allocate a
|
||||
temporary variable on the heap. Suggested by Sergey Kanatov in #5304.
|
@ -1,4 +0,0 @@
|
||||
Changes
|
||||
* Return PSA_ERROR_INVALID_ARGUMENT if the algorithm passed to one-shot
|
||||
AEAD functions is not an AEAD algorithm. This aligns them with the
|
||||
multipart functions, and the PSA Crypto API 1.1 specification.
|
@ -1,6 +0,0 @@
|
||||
Features
|
||||
* When MBEDTLS_PSA_CRYPTO_CONFIG is enabled, you may list the PSA crypto
|
||||
feature requirements in the file named by the new macro
|
||||
MBEDTLS_PSA_CRYPTO_CONFIG_FILE instead of the default psa/crypto_config.h.
|
||||
Furthermore you may name an additional file to include after the main
|
||||
file with the macro MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE.
|
@ -1,3 +0,0 @@
|
||||
Features
|
||||
* Add support for psa crypto key derivation for elliptic curve
|
||||
keys. Fixes #3260.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* Fix several bugs (warnings, compiler and linker errors, test failures)
|
||||
in reduced configurations when MBEDTLS_USE_PSA_CRYPTO is enabled.
|
@ -1,5 +0,0 @@
|
||||
New deprecations
|
||||
* Secure element drivers enabled by MBEDTLS_PSA_CRYPTO_SE_C are deprecated.
|
||||
This was intended as an experimental feature, but had not been explicitly
|
||||
documented as such. Use opaque drivers with the interface enabled by
|
||||
MBEDTLS_PSA_CRYPTO_DRIVERS instead.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* psa_raw_key_agreement() now returns PSA_ERROR_BUFFER_TOO_SMALL when
|
||||
applicable. Fixes #5735.
|
@ -1,4 +0,0 @@
|
||||
Features
|
||||
* Extend the existing PSA_ALG_TLS12_PSK_TO_MS() algorithm to support
|
||||
mixed-PSK. Add an optional input PSA_KEY_DERIVATION_INPUT_OTHER_SECRET
|
||||
holding the other secret.
|
@ -1,5 +0,0 @@
|
||||
Bugfix
|
||||
* Fix server connection identifier setting for outgoing encrypted records
|
||||
on DTLS 1.2 session resumption. After DTLS 1.2 session resumption with
|
||||
connection identifier, the Mbed TLS client now properly sends the server
|
||||
connection identifier in encrypted record headers. Fix #5872.
|
@ -1,2 +0,0 @@
|
||||
Bugfix
|
||||
* Silence a warning from GCC 12 in the selftest program. Fixes #5974.
|
@ -1,6 +0,0 @@
|
||||
Features
|
||||
* The structures mbedtls_ssl_config and mbedtls_ssl_context now store
|
||||
a piece of user data which is reserved for the application. The user
|
||||
data can be either a pointer or an integer.
|
||||
* Add an accessor function to get the configuration associated with
|
||||
an SSL context.
|
@ -1,3 +0,0 @@
|
||||
Features
|
||||
* Add a function to access the protocol version from an SSL context in a
|
||||
form that's easy to compare. Fixes #5407.
|
@ -1,2 +0,0 @@
|
||||
Bugfix
|
||||
* Fix mbedtls_ssl_get_version() not reporting TLSv1.3. Fixes #5406.
|
@ -1,3 +0,0 @@
|
||||
Changes
|
||||
* Add a CMake option that enables static linking of the runtime library
|
||||
in Microsoft Visual C++ compiler. Contributed by Microplankton.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* Fix compile errors when MBEDTLS_HAVE_TIME is not defined. Add tests
|
||||
to catch bad uses of time.h.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* Fix a TLS 1.3 handshake failure when the peer Finished message has not
|
||||
been received yet when we first try to fetch it.
|
@ -1,18 +0,0 @@
|
||||
Bugfix
|
||||
* Fix a TLS 1.3 handshake failure when the first attempt to send the client
|
||||
Finished message on the network cannot be satisfied. Fixes #5499.
|
||||
|
||||
Features
|
||||
* Add support for authentication of TLS 1.3 clients by TLS 1.3 servers.
|
||||
* Add support for server HelloRetryRequest message. The TLS 1.3 client is
|
||||
now capable of negotiating another shared secret if the one sent in its
|
||||
first ClientHello was not suitable to the server.
|
||||
* Add support for client-side TLS version negotiation. If both TLS 1.2 and
|
||||
TLS 1.3 protocols are enabled in the build of Mbed TLS, the TLS client now
|
||||
negotiates TLS 1.3 or TLS 1.2 with TLS servers.
|
||||
* Enable building of Mbed TLS with TLS 1.3 protocol support but without TLS
|
||||
1.2 protocol support.
|
||||
* Mbed TLS provides an implementation of a TLS 1.3 server (ephemeral key
|
||||
establishment only). See docs/architecture/tls13-support.md for a
|
||||
description of the support. The MBEDTLS_SSL_PROTO_TLS1_3 and
|
||||
MBEDTLS_SSL_SRV_C configuration options control this.
|
@ -1,4 +0,0 @@
|
||||
Bugfix
|
||||
* Fix check_config.h to check that we have MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
|
||||
when MBEDTLS_SSL_PROTO_TLS1_3 is specified, and make this and other
|
||||
dependencies explicit in the documentation. Fixes #5610.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* The TLS 1.3 implementation is now compatible with the
|
||||
MBEDTLS_USE_PSA_CRYPTO configuration option.
|
@ -1,3 +0,0 @@
|
||||
Bugfix
|
||||
* Fixed swap of client and server random bytes when exporting them alongside
|
||||
TLS 1.3 handshake and application traffic secret.
|
@ -1,7 +0,0 @@
|
||||
Bugfix
|
||||
* Fix a bug in (D)TLS curve negotiation: when MBEDTLS_USE_PSA_CRYPTO was
|
||||
enabled and an ECDHE-ECDSA or ECDHE-RSA key exchange was used, the
|
||||
client would fail to check that the curve selected by the server for
|
||||
ECDHE was indeed one that was offered. As a result, the client would
|
||||
accept any curve that it supported, even if that curve was not allowed
|
||||
according to its configuration. Fixes #5291.
|
@ -1,12 +0,0 @@
|
||||
Features
|
||||
* The configuration option MBEDTLS_USE_PSA_CRYPTO, which previously
|
||||
affected only a limited subset of crypto operations in TLS, X.509 and PK,
|
||||
now causes most of them to be done using PSA Crypto; see
|
||||
docs/use-psa-crypto.md for the list of exceptions.
|
||||
* The function mbedtls_pk_setup_opaque() now supports RSA key pairs as well.
|
||||
Opaque keys can now be used everywhere a private key is expected in the
|
||||
TLS and X.509 modules.
|
||||
* Opaque pre-shared keys for TLS, provisioned with
|
||||
mbedtls_ssl_conf_psk_opaque() or mbedtls_ssl_set_hs_psk_opaque(), which
|
||||
previously only worked for "pure" PSK key exchange, now can also be used
|
||||
for the "mixed" PSK key exchanges as well: ECDHE-PSK, DHE-PSK, RSA-PSK.
|
@ -1,3 +0,0 @@
|
||||
Features
|
||||
* Add the function mbedtls_x509_crt_has_ext_type() to access the ext types
|
||||
field within mbedtls_x509_crt context, as requested in #5585.
|
@ -1,4 +0,0 @@
|
||||
Security
|
||||
* Zeroize dynamically-allocated buffers used by the PSA Crypto key storage
|
||||
module before freeing them. These buffers contain secret key material, and
|
||||
could thus potentially leak the key through freed heap.
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @mainpage mbed TLS v3.1.0 source code documentation
|
||||
* @mainpage mbed TLS v3.2.0 source code documentation
|
||||
*
|
||||
* This documentation describes the internal structure of mbed TLS. It was
|
||||
* automatically generated from specially formatted comment blocks in
|
||||
|
@ -1,4 +1,4 @@
|
||||
PROJECT_NAME = "mbed TLS v3.1.0"
|
||||
PROJECT_NAME = "mbed TLS v3.2.0"
|
||||
OUTPUT_DIRECTORY = ../apidoc/
|
||||
FULL_PATH_NAMES = NO
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
|
@ -37,7 +37,7 @@
|
||||
* Major, Minor, Patchlevel
|
||||
*/
|
||||
#define MBEDTLS_VERSION_MAJOR 3
|
||||
#define MBEDTLS_VERSION_MINOR 1
|
||||
#define MBEDTLS_VERSION_MINOR 2
|
||||
#define MBEDTLS_VERSION_PATCH 0
|
||||
|
||||
/**
|
||||
@ -45,9 +45,9 @@
|
||||
* MMNNPP00
|
||||
* Major version | Minor version | Patch version
|
||||
*/
|
||||
#define MBEDTLS_VERSION_NUMBER 0x03010000
|
||||
#define MBEDTLS_VERSION_STRING "3.1.0"
|
||||
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 3.1.0"
|
||||
#define MBEDTLS_VERSION_NUMBER 0x03020000
|
||||
#define MBEDTLS_VERSION_STRING "3.2.0"
|
||||
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 3.2.0"
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
|
@ -385,6 +385,20 @@
|
||||
#error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_SETBUF_ALT) && !defined(MBEDTLS_PLATFORM_C)
|
||||
#error "MBEDTLS_PLATFORM_SETBUF_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_SETBUF_MACRO) && !defined(MBEDTLS_PLATFORM_C)
|
||||
#error "MBEDTLS_PLATFORM_SETBUF_MACRO defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_SETBUF_MACRO) &&\
|
||||
( defined(MBEDTLS_PLATFORM_STD_SETBUF) ||\
|
||||
defined(MBEDTLS_PLATFORM_SETBUF_ALT) )
|
||||
#error "MBEDTLS_PLATFORM_SETBUF_MACRO and MBEDTLS_PLATFORM_STD_SETBUF/MBEDTLS_PLATFORM_SETBUF_ALT cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\
|
||||
( !defined(MBEDTLS_PLATFORM_C) ||\
|
||||
!defined(MBEDTLS_HAVE_TIME) )
|
||||
|
@ -225,6 +225,7 @@
|
||||
* Uncomment a macro to enable alternate implementation of specific base
|
||||
* platform function
|
||||
*/
|
||||
//#define MBEDTLS_PLATFORM_SETBUF_ALT
|
||||
//#define MBEDTLS_PLATFORM_EXIT_ALT
|
||||
//#define MBEDTLS_PLATFORM_TIME_ALT
|
||||
//#define MBEDTLS_PLATFORM_FPRINTF_ALT
|
||||
@ -3328,6 +3329,7 @@
|
||||
//#define MBEDTLS_PLATFORM_STD_MEM_HDR <stdlib.h> /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */
|
||||
//#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_SETBUF setbuf /**< Default setbuf to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
|
||||
//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
|
||||
@ -3345,6 +3347,7 @@
|
||||
//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_SETBUF_MACRO setbuf /**< Default setbuf macro to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
|
||||
//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
|
||||
//#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */
|
||||
|
@ -216,32 +216,6 @@ typedef struct
|
||||
typedef void mbedtls_pk_restart_ctx;
|
||||
#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */
|
||||
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
/**
|
||||
* Quick access to an RSA context inside a PK context.
|
||||
*
|
||||
* \warning You must make sure the PK context actually holds an RSA context
|
||||
* before using this function!
|
||||
*/
|
||||
static inline mbedtls_rsa_context *mbedtls_pk_rsa( const mbedtls_pk_context pk )
|
||||
{
|
||||
return( (mbedtls_rsa_context *) (pk).MBEDTLS_PRIVATE(pk_ctx) );
|
||||
}
|
||||
#endif /* MBEDTLS_RSA_C */
|
||||
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
/**
|
||||
* Quick access to an EC context inside a PK context.
|
||||
*
|
||||
* \warning You must make sure the PK context actually holds an EC context
|
||||
* before using this function!
|
||||
*/
|
||||
static inline mbedtls_ecp_keypair *mbedtls_pk_ec( const mbedtls_pk_context pk )
|
||||
{
|
||||
return( (mbedtls_ecp_keypair *) (pk).MBEDTLS_PRIVATE(pk_ctx) );
|
||||
}
|
||||
#endif /* MBEDTLS_ECP_C */
|
||||
|
||||
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
|
||||
/**
|
||||
* \brief Types for RSA-alt abstraction
|
||||
@ -735,6 +709,55 @@ const char * mbedtls_pk_get_name( const mbedtls_pk_context *ctx );
|
||||
*/
|
||||
mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx );
|
||||
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
/**
|
||||
* Quick access to an RSA context inside a PK context.
|
||||
*
|
||||
* \warning This function can only be used when the type of the context, as
|
||||
* returned by mbedtls_pk_get_type(), is #MBEDTLS_PK_RSA.
|
||||
* Ensuring that is the caller's responsibility.
|
||||
* Alternatively, you can check whether this function returns NULL.
|
||||
*
|
||||
* \return The internal RSA context held by the PK context, or NULL.
|
||||
*/
|
||||
static inline mbedtls_rsa_context *mbedtls_pk_rsa( const mbedtls_pk_context pk )
|
||||
{
|
||||
switch( mbedtls_pk_get_type( &pk ) )
|
||||
{
|
||||
case MBEDTLS_PK_RSA:
|
||||
return( (mbedtls_rsa_context *) (pk).MBEDTLS_PRIVATE(pk_ctx) );
|
||||
default:
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_RSA_C */
|
||||
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
/**
|
||||
* Quick access to an EC context inside a PK context.
|
||||
*
|
||||
* \warning This function can only be used when the type of the context, as
|
||||
* returned by mbedtls_pk_get_type(), is #MBEDTLS_PK_ECKEY,
|
||||
* #MBEDTLS_PK_ECKEY_DH, or #MBEDTLS_PK_ECDSA.
|
||||
* Ensuring that is the caller's responsibility.
|
||||
* Alternatively, you can check whether this function returns NULL.
|
||||
*
|
||||
* \return The internal EC context held by the PK context, or NULL.
|
||||
*/
|
||||
static inline mbedtls_ecp_keypair *mbedtls_pk_ec( const mbedtls_pk_context pk )
|
||||
{
|
||||
switch( mbedtls_pk_get_type( &pk ) )
|
||||
{
|
||||
case MBEDTLS_PK_ECKEY:
|
||||
case MBEDTLS_PK_ECKEY_DH:
|
||||
case MBEDTLS_PK_ECDSA:
|
||||
return( (mbedtls_ecp_keypair *) (pk).MBEDTLS_PRIVATE(pk_ctx) );
|
||||
default:
|
||||
return( NULL );
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_ECP_C */
|
||||
|
||||
#if defined(MBEDTLS_PK_PARSE_C)
|
||||
/** \ingroup pk_module */
|
||||
/**
|
||||
|
@ -91,6 +91,9 @@ extern "C" {
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_FREE)
|
||||
#define MBEDTLS_PLATFORM_STD_FREE free /**< The default \c free function to use. */
|
||||
#endif
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_SETBUF)
|
||||
#define MBEDTLS_PLATFORM_STD_SETBUF setbuf /**< The default \c setbuf function to use. */
|
||||
#endif
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_EXIT)
|
||||
#define MBEDTLS_PLATFORM_STD_EXIT exit /**< The default \c exit function to use. */
|
||||
#endif
|
||||
@ -276,6 +279,56 @@ int mbedtls_platform_set_vsnprintf( int (*vsnprintf_func)( char * s, size_t n,
|
||||
#endif /* MBEDTLS_PLATFORM_VSNPRINTF_MACRO */
|
||||
#endif /* MBEDTLS_PLATFORM_VSNPRINTF_ALT */
|
||||
|
||||
/*
|
||||
* The function pointers for setbuf
|
||||
*/
|
||||
#if defined(MBEDTLS_PLATFORM_SETBUF_ALT)
|
||||
#include <stdio.h>
|
||||
/**
|
||||
* \brief Function pointer to call for `setbuf()` functionality
|
||||
* (changing the internal buffering on stdio calls).
|
||||
*
|
||||
* \note The library calls this function to disable
|
||||
* buffering when reading or writing sensitive data,
|
||||
* to avoid having extra copies of sensitive data
|
||||
* remaining in stdio buffers after the file is
|
||||
* closed. If this is not a concern, for example if
|
||||
* your platform's stdio doesn't have any buffering,
|
||||
* you can set mbedtls_setbuf to a function that
|
||||
* does nothing.
|
||||
*
|
||||
* The library always calls this function with
|
||||
* `buf` equal to `NULL`.
|
||||
*/
|
||||
extern void (*mbedtls_setbuf)( FILE *stream, char *buf );
|
||||
|
||||
/**
|
||||
* \brief Dynamically configure the function that is called
|
||||
* when the mbedtls_setbuf() function is called by the
|
||||
* library.
|
||||
*
|
||||
* \param setbuf_func The \c setbuf function implementation
|
||||
*
|
||||
* \return \c 0
|
||||
*/
|
||||
int mbedtls_platform_set_setbuf( void (*setbuf_func)(
|
||||
FILE *stream, char *buf ) );
|
||||
#elif defined(MBEDTLS_PLATFORM_SETBUF_MACRO)
|
||||
/**
|
||||
* \brief Macro defining the function for the library to
|
||||
* call for `setbuf` functionality (changing the
|
||||
* internal buffering on stdio calls).
|
||||
*
|
||||
* \note See extra comments on the mbedtls_setbuf() function
|
||||
* pointer above.
|
||||
*
|
||||
* \return \c 0 on success, negative on error.
|
||||
*/
|
||||
#define mbedtls_setbuf MBEDTLS_PLATFORM_SETBUF_MACRO
|
||||
#else
|
||||
#define mbedtls_setbuf setbuf
|
||||
#endif /* MBEDTLS_PLATFORM_SETBUF_ALT / MBEDTLS_PLATFORM_SETBUF_MACRO */
|
||||
|
||||
/*
|
||||
* The function pointers for exit
|
||||
*/
|
||||
|
@ -274,7 +274,7 @@ endif(USE_STATIC_MBEDTLS_LIBRARY)
|
||||
if(USE_SHARED_MBEDTLS_LIBRARY)
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_library(${mbedcrypto_target} SHARED ${src_crypto})
|
||||
set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 3.1.0 SOVERSION 11)
|
||||
set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 3.2.0 SOVERSION 12)
|
||||
target_link_libraries(${mbedcrypto_target} PUBLIC ${libs})
|
||||
|
||||
if(TARGET everest)
|
||||
@ -282,11 +282,11 @@ if(USE_SHARED_MBEDTLS_LIBRARY)
|
||||
endif()
|
||||
|
||||
add_library(${mbedx509_target} SHARED ${src_x509})
|
||||
set_target_properties(${mbedx509_target} PROPERTIES VERSION 3.1.0 SOVERSION 4)
|
||||
set_target_properties(${mbedx509_target} PROPERTIES VERSION 3.2.0 SOVERSION 4)
|
||||
target_link_libraries(${mbedx509_target} PUBLIC ${libs} ${mbedcrypto_target})
|
||||
|
||||
add_library(${mbedtls_target} SHARED ${src_tls})
|
||||
set_target_properties(${mbedtls_target} PROPERTIES VERSION 3.1.0 SOVERSION 17)
|
||||
set_target_properties(${mbedtls_target} PROPERTIES VERSION 3.2.0 SOVERSION 18)
|
||||
target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target})
|
||||
endif(USE_SHARED_MBEDTLS_LIBRARY)
|
||||
|
||||
|
@ -47,9 +47,9 @@ LOCAL_CFLAGS += -fPIC -fpic
|
||||
endif
|
||||
endif
|
||||
|
||||
SOEXT_TLS=so.17
|
||||
SOEXT_TLS=so.18
|
||||
SOEXT_X509=so.4
|
||||
SOEXT_CRYPTO=so.11
|
||||
SOEXT_CRYPTO=so.12
|
||||
|
||||
# Set AR_DASH= (empty string) to use an ar implementation that does not accept
|
||||
# the - prefix for command line options (e.g. llvm-ar)
|
||||
|
@ -1785,7 +1785,7 @@ int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_
|
||||
/*
|
||||
* handle trivial cases
|
||||
*/
|
||||
if( b == 1 )
|
||||
if( b == 1 || A->n == 0 )
|
||||
{
|
||||
*r = 0;
|
||||
return( 0 );
|
||||
|
@ -607,6 +607,9 @@ int mbedtls_ctr_drbg_write_seed_file( mbedtls_ctr_drbg_context *ctx,
|
||||
if( ( f = fopen( path, "wb" ) ) == NULL )
|
||||
return( MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR );
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( f, NULL );
|
||||
|
||||
if( ( ret = mbedtls_ctr_drbg_random( ctx, buf,
|
||||
MBEDTLS_CTR_DRBG_MAX_INPUT ) ) != 0 )
|
||||
goto exit;
|
||||
@ -640,6 +643,9 @@ int mbedtls_ctr_drbg_update_seed_file( mbedtls_ctr_drbg_context *ctx,
|
||||
if( ( f = fopen( path, "rb" ) ) == NULL )
|
||||
return( MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR );
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( f, NULL );
|
||||
|
||||
n = fread( buf, 1, sizeof( buf ), f );
|
||||
if( fread( &c, 1, 1, f ) != 0 )
|
||||
{
|
||||
|
@ -620,6 +620,7 @@ static int load_file( const char *path, unsigned char **buf, size_t *n )
|
||||
|
||||
if( ( f = fopen( path, "rb" ) ) == NULL )
|
||||
return( MBEDTLS_ERR_DHM_FILE_IO_ERROR );
|
||||
/* The data loaded here is public, so don't bother disabling buffering. */
|
||||
|
||||
fseek( f, 0, SEEK_END );
|
||||
if( ( size = ftell( f ) ) == -1 )
|
||||
|
@ -457,6 +457,9 @@ int mbedtls_entropy_write_seed_file( mbedtls_entropy_context *ctx, const char *p
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( f, NULL );
|
||||
|
||||
if( fwrite( buf, 1, MBEDTLS_ENTROPY_BLOCK_SIZE, f ) != MBEDTLS_ENTROPY_BLOCK_SIZE )
|
||||
{
|
||||
ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR;
|
||||
@ -484,6 +487,9 @@ int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *
|
||||
if( ( f = fopen( path, "rb" ) ) == NULL )
|
||||
return( MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR );
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( f, NULL );
|
||||
|
||||
fseek( f, 0, SEEK_END );
|
||||
n = (size_t) ftell( f );
|
||||
fseek( f, 0, SEEK_SET );
|
||||
|
@ -35,7 +35,7 @@
|
||||
#if defined(MBEDTLS_TIMING_C)
|
||||
#include "mbedtls/timing.h"
|
||||
#endif
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED) || !defined(HAVE_SYSCTL_ARND)
|
||||
#include "mbedtls/platform.h"
|
||||
#endif
|
||||
|
||||
@ -195,6 +195,9 @@ int mbedtls_platform_entropy_poll( void *data,
|
||||
if( file == NULL )
|
||||
return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( file, NULL );
|
||||
|
||||
read_len = fread( output, 1, len, file );
|
||||
if( read_len != len )
|
||||
{
|
||||
|
823
library/error.c
Normal file
823
library/error.c
Normal file
@ -0,0 +1,823 @@
|
||||
/*
|
||||
* Error message information
|
||||
*
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "mbedtls/error.h"
|
||||
|
||||
#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY)
|
||||
|
||||
#if defined(MBEDTLS_ERROR_C)
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#define mbedtls_snprintf snprintf
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(MBEDTLS_AES_C)
|
||||
#include "mbedtls/aes.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ARIA_C)
|
||||
#include "mbedtls/aria.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||
#include "mbedtls/asn1.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_BASE64_C)
|
||||
#include "mbedtls/base64.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_BIGNUM_C)
|
||||
#include "mbedtls/bignum.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CAMELLIA_C)
|
||||
#include "mbedtls/camellia.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CCM_C)
|
||||
#include "mbedtls/ccm.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CHACHA20_C)
|
||||
#include "mbedtls/chacha20.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CHACHAPOLY_C)
|
||||
#include "mbedtls/chachapoly.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_C)
|
||||
#include "mbedtls/cipher.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_DES_C)
|
||||
#include "mbedtls/des.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_DHM_C)
|
||||
#include "mbedtls/dhm.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
#include "mbedtls/ecp.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_C)
|
||||
#include "mbedtls/entropy.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ERROR_C)
|
||||
#include "mbedtls/error.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_GCM_C)
|
||||
#include "mbedtls/gcm.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HKDF_C)
|
||||
#include "mbedtls/hkdf.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HMAC_DRBG_C)
|
||||
#include "mbedtls/hmac_drbg.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_MD_C)
|
||||
#include "mbedtls/md.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_NET_C)
|
||||
#include "mbedtls/net_sockets.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_OID_C)
|
||||
#include "mbedtls/oid.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C)
|
||||
#include "mbedtls/pem.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PK_C)
|
||||
#include "mbedtls/pk.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PKCS12_C)
|
||||
#include "mbedtls/pkcs12.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PKCS5_C)
|
||||
#include "mbedtls/pkcs5.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_POLY1305_C)
|
||||
#include "mbedtls/poly1305.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
#include "mbedtls/rsa.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA1_C)
|
||||
#include "mbedtls/sha1.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
#include "mbedtls/sha256.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
#include "mbedtls/sha512.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_TLS_C)
|
||||
#include "mbedtls/ssl.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
#include "mbedtls/threading.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
|
||||
#include "mbedtls/x509.h"
|
||||
#endif
|
||||
|
||||
|
||||
const char * mbedtls_high_level_strerr( int error_code )
|
||||
{
|
||||
int high_level_error_code;
|
||||
|
||||
if( error_code < 0 )
|
||||
error_code = -error_code;
|
||||
|
||||
/* Extract the high-level part from the error code. */
|
||||
high_level_error_code = error_code & 0xFF80;
|
||||
|
||||
switch( high_level_error_code )
|
||||
{
|
||||
/* Begin Auto-Generated Code. */
|
||||
#if defined(MBEDTLS_CIPHER_C)
|
||||
case -(MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE):
|
||||
return( "CIPHER - The selected feature is not available" );
|
||||
case -(MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA):
|
||||
return( "CIPHER - Bad input parameters" );
|
||||
case -(MBEDTLS_ERR_CIPHER_ALLOC_FAILED):
|
||||
return( "CIPHER - Failed to allocate memory" );
|
||||
case -(MBEDTLS_ERR_CIPHER_INVALID_PADDING):
|
||||
return( "CIPHER - Input data contains invalid padding and is rejected" );
|
||||
case -(MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED):
|
||||
return( "CIPHER - Decryption of block requires a full block" );
|
||||
case -(MBEDTLS_ERR_CIPHER_AUTH_FAILED):
|
||||
return( "CIPHER - Authentication failed (for AEAD modes)" );
|
||||
case -(MBEDTLS_ERR_CIPHER_INVALID_CONTEXT):
|
||||
return( "CIPHER - The context is invalid. For example, because it was freed" );
|
||||
#endif /* MBEDTLS_CIPHER_C */
|
||||
|
||||
#if defined(MBEDTLS_DHM_C)
|
||||
case -(MBEDTLS_ERR_DHM_BAD_INPUT_DATA):
|
||||
return( "DHM - Bad input parameters" );
|
||||
case -(MBEDTLS_ERR_DHM_READ_PARAMS_FAILED):
|
||||
return( "DHM - Reading of the DHM parameters failed" );
|
||||
case -(MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED):
|
||||
return( "DHM - Making of the DHM parameters failed" );
|
||||
case -(MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED):
|
||||
return( "DHM - Reading of the public values failed" );
|
||||
case -(MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED):
|
||||
return( "DHM - Making of the public value failed" );
|
||||
case -(MBEDTLS_ERR_DHM_CALC_SECRET_FAILED):
|
||||
return( "DHM - Calculation of the DHM secret failed" );
|
||||
case -(MBEDTLS_ERR_DHM_INVALID_FORMAT):
|
||||
return( "DHM - The ASN.1 data is not formatted correctly" );
|
||||
case -(MBEDTLS_ERR_DHM_ALLOC_FAILED):
|
||||
return( "DHM - Allocation of memory failed" );
|
||||
case -(MBEDTLS_ERR_DHM_FILE_IO_ERROR):
|
||||
return( "DHM - Read or write of file failed" );
|
||||
case -(MBEDTLS_ERR_DHM_SET_GROUP_FAILED):
|
||||
return( "DHM - Setting the modulus and generator failed" );
|
||||
#endif /* MBEDTLS_DHM_C */
|
||||
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
case -(MBEDTLS_ERR_ECP_BAD_INPUT_DATA):
|
||||
return( "ECP - Bad input parameters to function" );
|
||||
case -(MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL):
|
||||
return( "ECP - The buffer is too small to write to" );
|
||||
case -(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE):
|
||||
return( "ECP - The requested feature is not available, for example, the requested curve is not supported" );
|
||||
case -(MBEDTLS_ERR_ECP_VERIFY_FAILED):
|
||||
return( "ECP - The signature is not valid" );
|
||||
case -(MBEDTLS_ERR_ECP_ALLOC_FAILED):
|
||||
return( "ECP - Memory allocation failed" );
|
||||
case -(MBEDTLS_ERR_ECP_RANDOM_FAILED):
|
||||
return( "ECP - Generation of random value, such as ephemeral key, failed" );
|
||||
case -(MBEDTLS_ERR_ECP_INVALID_KEY):
|
||||
return( "ECP - Invalid private or public key" );
|
||||
case -(MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH):
|
||||
return( "ECP - The buffer contains a valid signature followed by more data" );
|
||||
case -(MBEDTLS_ERR_ECP_IN_PROGRESS):
|
||||
return( "ECP - Operation in progress, call again with the same parameters to continue" );
|
||||
#endif /* MBEDTLS_ECP_C */
|
||||
|
||||
#if defined(MBEDTLS_MD_C)
|
||||
case -(MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE):
|
||||
return( "MD - The selected feature is not available" );
|
||||
case -(MBEDTLS_ERR_MD_BAD_INPUT_DATA):
|
||||
return( "MD - Bad input parameters to function" );
|
||||
case -(MBEDTLS_ERR_MD_ALLOC_FAILED):
|
||||
return( "MD - Failed to allocate memory" );
|
||||
case -(MBEDTLS_ERR_MD_FILE_IO_ERROR):
|
||||
return( "MD - Opening or reading of file failed" );
|
||||
#endif /* MBEDTLS_MD_C */
|
||||
|
||||
#if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C)
|
||||
case -(MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT):
|
||||
return( "PEM - No PEM header or footer found" );
|
||||
case -(MBEDTLS_ERR_PEM_INVALID_DATA):
|
||||
return( "PEM - PEM string is not as expected" );
|
||||
case -(MBEDTLS_ERR_PEM_ALLOC_FAILED):
|
||||
return( "PEM - Failed to allocate memory" );
|
||||
case -(MBEDTLS_ERR_PEM_INVALID_ENC_IV):
|
||||
return( "PEM - RSA IV is not in hex-format" );
|
||||
case -(MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG):
|
||||
return( "PEM - Unsupported key encryption algorithm" );
|
||||
case -(MBEDTLS_ERR_PEM_PASSWORD_REQUIRED):
|
||||
return( "PEM - Private key password can't be empty" );
|
||||
case -(MBEDTLS_ERR_PEM_PASSWORD_MISMATCH):
|
||||
return( "PEM - Given private key password does not allow for correct decryption" );
|
||||
case -(MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE):
|
||||
return( "PEM - Unavailable feature, e.g. hashing/encryption combination" );
|
||||
case -(MBEDTLS_ERR_PEM_BAD_INPUT_DATA):
|
||||
return( "PEM - Bad input parameters to function" );
|
||||
#endif /* MBEDTLS_PEM_PARSE_C || MBEDTLS_PEM_WRITE_C */
|
||||
|
||||
#if defined(MBEDTLS_PK_C)
|
||||
case -(MBEDTLS_ERR_PK_ALLOC_FAILED):
|
||||
return( "PK - Memory allocation failed" );
|
||||
case -(MBEDTLS_ERR_PK_TYPE_MISMATCH):
|
||||
return( "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" );
|
||||
case -(MBEDTLS_ERR_PK_BAD_INPUT_DATA):
|
||||
return( "PK - Bad input parameters to function" );
|
||||
case -(MBEDTLS_ERR_PK_FILE_IO_ERROR):
|
||||
return( "PK - Read/write of file failed" );
|
||||
case -(MBEDTLS_ERR_PK_KEY_INVALID_VERSION):
|
||||
return( "PK - Unsupported key version" );
|
||||
case -(MBEDTLS_ERR_PK_KEY_INVALID_FORMAT):
|
||||
return( "PK - Invalid key tag or value" );
|
||||
case -(MBEDTLS_ERR_PK_UNKNOWN_PK_ALG):
|
||||
return( "PK - Key algorithm is unsupported (only RSA and EC are supported)" );
|
||||
case -(MBEDTLS_ERR_PK_PASSWORD_REQUIRED):
|
||||
return( "PK - Private key password can't be empty" );
|
||||
case -(MBEDTLS_ERR_PK_PASSWORD_MISMATCH):
|
||||
return( "PK - Given private key password does not allow for correct decryption" );
|
||||
case -(MBEDTLS_ERR_PK_INVALID_PUBKEY):
|
||||
return( "PK - The pubkey tag or value is invalid (only RSA and EC are supported)" );
|
||||
case -(MBEDTLS_ERR_PK_INVALID_ALG):
|
||||
return( "PK - The algorithm tag or value is invalid" );
|
||||
case -(MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE):
|
||||
return( "PK - Elliptic curve is unsupported (only NIST curves are supported)" );
|
||||
case -(MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE):
|
||||
return( "PK - Unavailable feature, e.g. RSA disabled for RSA key" );
|
||||
case -(MBEDTLS_ERR_PK_SIG_LEN_MISMATCH):
|
||||
return( "PK - The buffer contains a valid signature followed by more data" );
|
||||
case -(MBEDTLS_ERR_PK_BUFFER_TOO_SMALL):
|
||||
return( "PK - The output buffer is too small" );
|
||||
#endif /* MBEDTLS_PK_C */
|
||||
|
||||
#if defined(MBEDTLS_PKCS12_C)
|
||||
case -(MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA):
|
||||
return( "PKCS12 - Bad input parameters to function" );
|
||||
case -(MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE):
|
||||
return( "PKCS12 - Feature not available, e.g. unsupported encryption scheme" );
|
||||
case -(MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT):
|
||||
return( "PKCS12 - PBE ASN.1 data not as expected" );
|
||||
case -(MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH):
|
||||
return( "PKCS12 - Given private key password does not allow for correct decryption" );
|
||||
#endif /* MBEDTLS_PKCS12_C */
|
||||
|
||||
#if defined(MBEDTLS_PKCS5_C)
|
||||
case -(MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA):
|
||||
return( "PKCS5 - Bad input parameters to function" );
|
||||
case -(MBEDTLS_ERR_PKCS5_INVALID_FORMAT):
|
||||
return( "PKCS5 - Unexpected ASN.1 data" );
|
||||
case -(MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE):
|
||||
return( "PKCS5 - Requested encryption or digest alg not available" );
|
||||
case -(MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH):
|
||||
return( "PKCS5 - Given private key password does not allow for correct decryption" );
|
||||
#endif /* MBEDTLS_PKCS5_C */
|
||||
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
case -(MBEDTLS_ERR_RSA_BAD_INPUT_DATA):
|
||||
return( "RSA - Bad input parameters to function" );
|
||||
case -(MBEDTLS_ERR_RSA_INVALID_PADDING):
|
||||
return( "RSA - Input data contains invalid padding and is rejected" );
|
||||
case -(MBEDTLS_ERR_RSA_KEY_GEN_FAILED):
|
||||
return( "RSA - Something failed during generation of a key" );
|
||||
case -(MBEDTLS_ERR_RSA_KEY_CHECK_FAILED):
|
||||
return( "RSA - Key failed to pass the validity check of the library" );
|
||||
case -(MBEDTLS_ERR_RSA_PUBLIC_FAILED):
|
||||
return( "RSA - The public key operation failed" );
|
||||
case -(MBEDTLS_ERR_RSA_PRIVATE_FAILED):
|
||||
return( "RSA - The private key operation failed" );
|
||||
case -(MBEDTLS_ERR_RSA_VERIFY_FAILED):
|
||||
return( "RSA - The PKCS#1 verification failed" );
|
||||
case -(MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE):
|
||||
return( "RSA - The output buffer for decryption is not large enough" );
|
||||
case -(MBEDTLS_ERR_RSA_RNG_FAILED):
|
||||
return( "RSA - The random generator failed to generate non-zeros" );
|
||||
#endif /* MBEDTLS_RSA_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_TLS_C)
|
||||
case -(MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS):
|
||||
return( "SSL - A cryptographic operation is in progress. Try again later" );
|
||||
case -(MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE):
|
||||
return( "SSL - The requested feature is not available" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_INPUT_DATA):
|
||||
return( "SSL - Bad input parameters to function" );
|
||||
case -(MBEDTLS_ERR_SSL_INVALID_MAC):
|
||||
return( "SSL - Verification of the message MAC failed" );
|
||||
case -(MBEDTLS_ERR_SSL_INVALID_RECORD):
|
||||
return( "SSL - An invalid SSL record was received" );
|
||||
case -(MBEDTLS_ERR_SSL_CONN_EOF):
|
||||
return( "SSL - The connection indicated an EOF" );
|
||||
case -(MBEDTLS_ERR_SSL_DECODE_ERROR):
|
||||
return( "SSL - A message could not be parsed due to a syntactic error" );
|
||||
case -(MBEDTLS_ERR_SSL_NO_RNG):
|
||||
return( "SSL - No RNG was provided to the SSL module" );
|
||||
case -(MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE):
|
||||
return( "SSL - No client certification received from the client, but required by the authentication mode" );
|
||||
case -(MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION):
|
||||
return( "SSL - Client received an extended server hello containing an unsupported extension" );
|
||||
case -(MBEDTLS_ERR_SSL_NO_APPLICATION_PROTOCOL):
|
||||
return( "SSL - No ALPN protocols supported that the client advertises" );
|
||||
case -(MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED):
|
||||
return( "SSL - The own private key or pre-shared key is not set, but needed" );
|
||||
case -(MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED):
|
||||
return( "SSL - No CA Chain is set, but required to operate" );
|
||||
case -(MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE):
|
||||
return( "SSL - An unexpected message was received from our peer" );
|
||||
case -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE):
|
||||
return( "SSL - A fatal alert message was received from our peer" );
|
||||
case -(MBEDTLS_ERR_SSL_UNRECOGNIZED_NAME):
|
||||
return( "SSL - No server could be identified matching the client's SNI" );
|
||||
case -(MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY):
|
||||
return( "SSL - The peer notified us that the connection is going to be closed" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_CERTIFICATE):
|
||||
return( "SSL - Processing of the Certificate handshake message failed" );
|
||||
case -(MBEDTLS_ERR_SSL_ALLOC_FAILED):
|
||||
return( "SSL - Memory allocation failed" );
|
||||
case -(MBEDTLS_ERR_SSL_HW_ACCEL_FAILED):
|
||||
return( "SSL - Hardware acceleration function returned with error" );
|
||||
case -(MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH):
|
||||
return( "SSL - Hardware acceleration function skipped / left alone data" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION):
|
||||
return( "SSL - Handshake protocol not within min/max boundaries" );
|
||||
case -(MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE):
|
||||
return( "SSL - The handshake negotiation failed" );
|
||||
case -(MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED):
|
||||
return( "SSL - Session ticket has expired" );
|
||||
case -(MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH):
|
||||
return( "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)" );
|
||||
case -(MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY):
|
||||
return( "SSL - Unknown identity received (eg, PSK identity)" );
|
||||
case -(MBEDTLS_ERR_SSL_INTERNAL_ERROR):
|
||||
return( "SSL - Internal error (eg, unexpected failure in lower-level module)" );
|
||||
case -(MBEDTLS_ERR_SSL_COUNTER_WRAPPING):
|
||||
return( "SSL - A counter would wrap (eg, too many messages exchanged)" );
|
||||
case -(MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO):
|
||||
return( "SSL - Unexpected message at ServerHello in renegotiation" );
|
||||
case -(MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED):
|
||||
return( "SSL - DTLS client must retry for hello verification" );
|
||||
case -(MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL):
|
||||
return( "SSL - A buffer is too small to receive or write a message" );
|
||||
case -(MBEDTLS_ERR_SSL_WANT_READ):
|
||||
return( "SSL - No data of requested type currently available on underlying transport" );
|
||||
case -(MBEDTLS_ERR_SSL_WANT_WRITE):
|
||||
return( "SSL - Connection requires a write call" );
|
||||
case -(MBEDTLS_ERR_SSL_TIMEOUT):
|
||||
return( "SSL - The operation timed out" );
|
||||
case -(MBEDTLS_ERR_SSL_CLIENT_RECONNECT):
|
||||
return( "SSL - The client initiated a reconnect from the same port" );
|
||||
case -(MBEDTLS_ERR_SSL_UNEXPECTED_RECORD):
|
||||
return( "SSL - Record header looks valid but is not expected" );
|
||||
case -(MBEDTLS_ERR_SSL_NON_FATAL):
|
||||
return( "SSL - The alert message received indicates a non-fatal error" );
|
||||
case -(MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER):
|
||||
return( "SSL - A field in a message was incorrect or inconsistent with other fields" );
|
||||
case -(MBEDTLS_ERR_SSL_CONTINUE_PROCESSING):
|
||||
return( "SSL - Internal-only message signaling that further message-processing should be done" );
|
||||
case -(MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS):
|
||||
return( "SSL - The asynchronous operation is not completed yet" );
|
||||
case -(MBEDTLS_ERR_SSL_EARLY_MESSAGE):
|
||||
return( "SSL - Internal-only message signaling that a message arrived early" );
|
||||
case -(MBEDTLS_ERR_SSL_UNEXPECTED_CID):
|
||||
return( "SSL - An encrypted DTLS-frame with an unexpected CID was received" );
|
||||
case -(MBEDTLS_ERR_SSL_VERSION_MISMATCH):
|
||||
return( "SSL - An operation failed due to an unexpected version or configuration" );
|
||||
case -(MBEDTLS_ERR_SSL_BAD_CONFIG):
|
||||
return( "SSL - Invalid value in SSL config" );
|
||||
#endif /* MBEDTLS_SSL_TLS_C */
|
||||
|
||||
#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
|
||||
case -(MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE):
|
||||
return( "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" );
|
||||
case -(MBEDTLS_ERR_X509_UNKNOWN_OID):
|
||||
return( "X509 - Requested OID is unknown" );
|
||||
case -(MBEDTLS_ERR_X509_INVALID_FORMAT):
|
||||
return( "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected" );
|
||||
case -(MBEDTLS_ERR_X509_INVALID_VERSION):
|
||||
return( "X509 - The CRT/CRL/CSR version element is invalid" );
|
||||
case -(MBEDTLS_ERR_X509_INVALID_SERIAL):
|
||||
return( "X509 - The serial tag or value is invalid" );
|
||||
case -(MBEDTLS_ERR_X509_INVALID_ALG):
|
||||
return( "X509 - The algorithm tag or value is invalid" );
|
||||
case -(MBEDTLS_ERR_X509_INVALID_NAME):
|
||||
return( "X509 - The name tag or value is invalid" );
|
||||
case -(MBEDTLS_ERR_X509_INVALID_DATE):
|
||||
return( "X509 - The date tag or value is invalid" );
|
||||
case -(MBEDTLS_ERR_X509_INVALID_SIGNATURE):
|
||||
return( "X509 - The signature tag or value invalid" );
|
||||
case -(MBEDTLS_ERR_X509_INVALID_EXTENSIONS):
|
||||
return( "X509 - The extension tag or value is invalid" );
|
||||
case -(MBEDTLS_ERR_X509_UNKNOWN_VERSION):
|
||||
return( "X509 - CRT/CRL/CSR has an unsupported version number" );
|
||||
case -(MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG):
|
||||
return( "X509 - Signature algorithm (oid) is unsupported" );
|
||||
case -(MBEDTLS_ERR_X509_SIG_MISMATCH):
|
||||
return( "X509 - Signature algorithms do not match. (see \\c ::mbedtls_x509_crt sig_oid)" );
|
||||
case -(MBEDTLS_ERR_X509_CERT_VERIFY_FAILED):
|
||||
return( "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" );
|
||||
case -(MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT):
|
||||
return( "X509 - Format not recognized as DER or PEM" );
|
||||
case -(MBEDTLS_ERR_X509_BAD_INPUT_DATA):
|
||||
return( "X509 - Input invalid" );
|
||||
case -(MBEDTLS_ERR_X509_ALLOC_FAILED):
|
||||
return( "X509 - Allocation of memory failed" );
|
||||
case -(MBEDTLS_ERR_X509_FILE_IO_ERROR):
|
||||
return( "X509 - Read/write of file failed" );
|
||||
case -(MBEDTLS_ERR_X509_BUFFER_TOO_SMALL):
|
||||
return( "X509 - Destination buffer is too small" );
|
||||
case -(MBEDTLS_ERR_X509_FATAL_ERROR):
|
||||
return( "X509 - A fatal error occurred, eg the chain is too long or the vrfy callback failed" );
|
||||
#endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */
|
||||
/* End Auto-Generated Code. */
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
const char * mbedtls_low_level_strerr( int error_code )
|
||||
{
|
||||
int low_level_error_code;
|
||||
|
||||
if( error_code < 0 )
|
||||
error_code = -error_code;
|
||||
|
||||
/* Extract the low-level part from the error code. */
|
||||
low_level_error_code = error_code & ~0xFF80;
|
||||
|
||||
switch( low_level_error_code )
|
||||
{
|
||||
/* Begin Auto-Generated Code. */
|
||||
#if defined(MBEDTLS_AES_C)
|
||||
case -(MBEDTLS_ERR_AES_INVALID_KEY_LENGTH):
|
||||
return( "AES - Invalid key length" );
|
||||
case -(MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH):
|
||||
return( "AES - Invalid data input length" );
|
||||
case -(MBEDTLS_ERR_AES_BAD_INPUT_DATA):
|
||||
return( "AES - Invalid input data" );
|
||||
#endif /* MBEDTLS_AES_C */
|
||||
|
||||
#if defined(MBEDTLS_ARIA_C)
|
||||
case -(MBEDTLS_ERR_ARIA_BAD_INPUT_DATA):
|
||||
return( "ARIA - Bad input data" );
|
||||
case -(MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH):
|
||||
return( "ARIA - Invalid data input length" );
|
||||
#endif /* MBEDTLS_ARIA_C */
|
||||
|
||||
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||
case -(MBEDTLS_ERR_ASN1_OUT_OF_DATA):
|
||||
return( "ASN1 - Out of data when parsing an ASN1 data structure" );
|
||||
case -(MBEDTLS_ERR_ASN1_UNEXPECTED_TAG):
|
||||
return( "ASN1 - ASN1 tag was of an unexpected value" );
|
||||
case -(MBEDTLS_ERR_ASN1_INVALID_LENGTH):
|
||||
return( "ASN1 - Error when trying to determine the length or invalid length" );
|
||||
case -(MBEDTLS_ERR_ASN1_LENGTH_MISMATCH):
|
||||
return( "ASN1 - Actual length differs from expected length" );
|
||||
case -(MBEDTLS_ERR_ASN1_INVALID_DATA):
|
||||
return( "ASN1 - Data is invalid" );
|
||||
case -(MBEDTLS_ERR_ASN1_ALLOC_FAILED):
|
||||
return( "ASN1 - Memory allocation failed" );
|
||||
case -(MBEDTLS_ERR_ASN1_BUF_TOO_SMALL):
|
||||
return( "ASN1 - Buffer too small when writing ASN.1 data structure" );
|
||||
#endif /* MBEDTLS_ASN1_PARSE_C */
|
||||
|
||||
#if defined(MBEDTLS_BASE64_C)
|
||||
case -(MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL):
|
||||
return( "BASE64 - Output buffer too small" );
|
||||
case -(MBEDTLS_ERR_BASE64_INVALID_CHARACTER):
|
||||
return( "BASE64 - Invalid character in input" );
|
||||
#endif /* MBEDTLS_BASE64_C */
|
||||
|
||||
#if defined(MBEDTLS_BIGNUM_C)
|
||||
case -(MBEDTLS_ERR_MPI_FILE_IO_ERROR):
|
||||
return( "BIGNUM - An error occurred while reading from or writing to a file" );
|
||||
case -(MBEDTLS_ERR_MPI_BAD_INPUT_DATA):
|
||||
return( "BIGNUM - Bad input parameters to function" );
|
||||
case -(MBEDTLS_ERR_MPI_INVALID_CHARACTER):
|
||||
return( "BIGNUM - There is an invalid character in the digit string" );
|
||||
case -(MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL):
|
||||
return( "BIGNUM - The buffer is too small to write to" );
|
||||
case -(MBEDTLS_ERR_MPI_NEGATIVE_VALUE):
|
||||
return( "BIGNUM - The input arguments are negative or result in illegal output" );
|
||||
case -(MBEDTLS_ERR_MPI_DIVISION_BY_ZERO):
|
||||
return( "BIGNUM - The input argument for division is zero, which is not allowed" );
|
||||
case -(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE):
|
||||
return( "BIGNUM - The input arguments are not acceptable" );
|
||||
case -(MBEDTLS_ERR_MPI_ALLOC_FAILED):
|
||||
return( "BIGNUM - Memory allocation failed" );
|
||||
#endif /* MBEDTLS_BIGNUM_C */
|
||||
|
||||
#if defined(MBEDTLS_CAMELLIA_C)
|
||||
case -(MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA):
|
||||
return( "CAMELLIA - Bad input data" );
|
||||
case -(MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH):
|
||||
return( "CAMELLIA - Invalid data input length" );
|
||||
#endif /* MBEDTLS_CAMELLIA_C */
|
||||
|
||||
#if defined(MBEDTLS_CCM_C)
|
||||
case -(MBEDTLS_ERR_CCM_BAD_INPUT):
|
||||
return( "CCM - Bad input parameters to the function" );
|
||||
case -(MBEDTLS_ERR_CCM_AUTH_FAILED):
|
||||
return( "CCM - Authenticated decryption failed" );
|
||||
#endif /* MBEDTLS_CCM_C */
|
||||
|
||||
#if defined(MBEDTLS_CHACHA20_C)
|
||||
case -(MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA):
|
||||
return( "CHACHA20 - Invalid input parameter(s)" );
|
||||
#endif /* MBEDTLS_CHACHA20_C */
|
||||
|
||||
#if defined(MBEDTLS_CHACHAPOLY_C)
|
||||
case -(MBEDTLS_ERR_CHACHAPOLY_BAD_STATE):
|
||||
return( "CHACHAPOLY - The requested operation is not permitted in the current state" );
|
||||
case -(MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED):
|
||||
return( "CHACHAPOLY - Authenticated decryption failed: data was not authentic" );
|
||||
#endif /* MBEDTLS_CHACHAPOLY_C */
|
||||
|
||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||
case -(MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED):
|
||||
return( "CTR_DRBG - The entropy source failed" );
|
||||
case -(MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG):
|
||||
return( "CTR_DRBG - The requested random buffer length is too big" );
|
||||
case -(MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG):
|
||||
return( "CTR_DRBG - The input (entropy + additional data) is too large" );
|
||||
case -(MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR):
|
||||
return( "CTR_DRBG - Read or write error in file" );
|
||||
#endif /* MBEDTLS_CTR_DRBG_C */
|
||||
|
||||
#if defined(MBEDTLS_DES_C)
|
||||
case -(MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH):
|
||||
return( "DES - The data input has an invalid length" );
|
||||
#endif /* MBEDTLS_DES_C */
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_C)
|
||||
case -(MBEDTLS_ERR_ENTROPY_SOURCE_FAILED):
|
||||
return( "ENTROPY - Critical entropy source failure" );
|
||||
case -(MBEDTLS_ERR_ENTROPY_MAX_SOURCES):
|
||||
return( "ENTROPY - No more sources can be added" );
|
||||
case -(MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED):
|
||||
return( "ENTROPY - No sources have been added to poll" );
|
||||
case -(MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE):
|
||||
return( "ENTROPY - No strong sources have been added to poll" );
|
||||
case -(MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR):
|
||||
return( "ENTROPY - Read/write error in file" );
|
||||
#endif /* MBEDTLS_ENTROPY_C */
|
||||
|
||||
#if defined(MBEDTLS_ERROR_C)
|
||||
case -(MBEDTLS_ERR_ERROR_GENERIC_ERROR):
|
||||
return( "ERROR - Generic error" );
|
||||
case -(MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED):
|
||||
return( "ERROR - This is a bug in the library" );
|
||||
#endif /* MBEDTLS_ERROR_C */
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
case -(MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED):
|
||||
return( "PLATFORM - Hardware accelerator failed" );
|
||||
case -(MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED):
|
||||
return( "PLATFORM - The requested feature is not supported by the platform" );
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
|
||||
#if defined(MBEDTLS_GCM_C)
|
||||
case -(MBEDTLS_ERR_GCM_AUTH_FAILED):
|
||||
return( "GCM - Authenticated decryption failed" );
|
||||
case -(MBEDTLS_ERR_GCM_BAD_INPUT):
|
||||
return( "GCM - Bad input parameters to function" );
|
||||
case -(MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL):
|
||||
return( "GCM - An output buffer is too small" );
|
||||
#endif /* MBEDTLS_GCM_C */
|
||||
|
||||
#if defined(MBEDTLS_HKDF_C)
|
||||
case -(MBEDTLS_ERR_HKDF_BAD_INPUT_DATA):
|
||||
return( "HKDF - Bad input parameters to function" );
|
||||
#endif /* MBEDTLS_HKDF_C */
|
||||
|
||||
#if defined(MBEDTLS_HMAC_DRBG_C)
|
||||
case -(MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG):
|
||||
return( "HMAC_DRBG - Too many random requested in single call" );
|
||||
case -(MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG):
|
||||
return( "HMAC_DRBG - Input too large (Entropy + additional)" );
|
||||
case -(MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR):
|
||||
return( "HMAC_DRBG - Read/write error in file" );
|
||||
case -(MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED):
|
||||
return( "HMAC_DRBG - The entropy source failed" );
|
||||
#endif /* MBEDTLS_HMAC_DRBG_C */
|
||||
|
||||
#if defined(MBEDTLS_NET_C)
|
||||
case -(MBEDTLS_ERR_NET_SOCKET_FAILED):
|
||||
return( "NET - Failed to open a socket" );
|
||||
case -(MBEDTLS_ERR_NET_CONNECT_FAILED):
|
||||
return( "NET - The connection to the given server / port failed" );
|
||||
case -(MBEDTLS_ERR_NET_BIND_FAILED):
|
||||
return( "NET - Binding of the socket failed" );
|
||||
case -(MBEDTLS_ERR_NET_LISTEN_FAILED):
|
||||
return( "NET - Could not listen on the socket" );
|
||||
case -(MBEDTLS_ERR_NET_ACCEPT_FAILED):
|
||||
return( "NET - Could not accept the incoming connection" );
|
||||
case -(MBEDTLS_ERR_NET_RECV_FAILED):
|
||||
return( "NET - Reading information from the socket failed" );
|
||||
case -(MBEDTLS_ERR_NET_SEND_FAILED):
|
||||
return( "NET - Sending information through the socket failed" );
|
||||
case -(MBEDTLS_ERR_NET_CONN_RESET):
|
||||
return( "NET - Connection was reset by peer" );
|
||||
case -(MBEDTLS_ERR_NET_UNKNOWN_HOST):
|
||||
return( "NET - Failed to get an IP address for the given hostname" );
|
||||
case -(MBEDTLS_ERR_NET_BUFFER_TOO_SMALL):
|
||||
return( "NET - Buffer is too small to hold the data" );
|
||||
case -(MBEDTLS_ERR_NET_INVALID_CONTEXT):
|
||||
return( "NET - The context is invalid, eg because it was free()ed" );
|
||||
case -(MBEDTLS_ERR_NET_POLL_FAILED):
|
||||
return( "NET - Polling the net context failed" );
|
||||
case -(MBEDTLS_ERR_NET_BAD_INPUT_DATA):
|
||||
return( "NET - Input invalid" );
|
||||
#endif /* MBEDTLS_NET_C */
|
||||
|
||||
#if defined(MBEDTLS_OID_C)
|
||||
case -(MBEDTLS_ERR_OID_NOT_FOUND):
|
||||
return( "OID - OID is not found" );
|
||||
case -(MBEDTLS_ERR_OID_BUF_TOO_SMALL):
|
||||
return( "OID - output buffer is too small" );
|
||||
#endif /* MBEDTLS_OID_C */
|
||||
|
||||
#if defined(MBEDTLS_POLY1305_C)
|
||||
case -(MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA):
|
||||
return( "POLY1305 - Invalid input parameter(s)" );
|
||||
#endif /* MBEDTLS_POLY1305_C */
|
||||
|
||||
#if defined(MBEDTLS_SHA1_C)
|
||||
case -(MBEDTLS_ERR_SHA1_BAD_INPUT_DATA):
|
||||
return( "SHA1 - SHA-1 input data was malformed" );
|
||||
#endif /* MBEDTLS_SHA1_C */
|
||||
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
case -(MBEDTLS_ERR_SHA256_BAD_INPUT_DATA):
|
||||
return( "SHA256 - SHA-256 input data was malformed" );
|
||||
#endif /* MBEDTLS_SHA256_C */
|
||||
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
case -(MBEDTLS_ERR_SHA512_BAD_INPUT_DATA):
|
||||
return( "SHA512 - SHA-512 input data was malformed" );
|
||||
#endif /* MBEDTLS_SHA512_C */
|
||||
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
case -(MBEDTLS_ERR_THREADING_BAD_INPUT_DATA):
|
||||
return( "THREADING - Bad input parameters to function" );
|
||||
case -(MBEDTLS_ERR_THREADING_MUTEX_ERROR):
|
||||
return( "THREADING - Locking / unlocking / free failed with error code" );
|
||||
#endif /* MBEDTLS_THREADING_C */
|
||||
/* End Auto-Generated Code. */
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
void mbedtls_strerror( int ret, char *buf, size_t buflen )
|
||||
{
|
||||
size_t len;
|
||||
int use_ret;
|
||||
const char * high_level_error_description = NULL;
|
||||
const char * low_level_error_description = NULL;
|
||||
|
||||
if( buflen == 0 )
|
||||
return;
|
||||
|
||||
memset( buf, 0x00, buflen );
|
||||
|
||||
if( ret < 0 )
|
||||
ret = -ret;
|
||||
|
||||
if( ret & 0xFF80 )
|
||||
{
|
||||
use_ret = ret & 0xFF80;
|
||||
|
||||
// Translate high level error code.
|
||||
high_level_error_description = mbedtls_high_level_strerr( ret );
|
||||
|
||||
if( high_level_error_description == NULL )
|
||||
mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", (unsigned int) use_ret );
|
||||
else
|
||||
mbedtls_snprintf( buf, buflen, "%s", high_level_error_description );
|
||||
|
||||
#if defined(MBEDTLS_SSL_TLS_C)
|
||||
// Early return in case of a fatal error - do not try to translate low
|
||||
// level code.
|
||||
if(use_ret == -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE))
|
||||
return;
|
||||
#endif /* MBEDTLS_SSL_TLS_C */
|
||||
}
|
||||
|
||||
use_ret = ret & ~0xFF80;
|
||||
|
||||
if( use_ret == 0 )
|
||||
return;
|
||||
|
||||
// If high level code is present, make a concatenation between both
|
||||
// error strings.
|
||||
//
|
||||
len = strlen( buf );
|
||||
|
||||
if( len > 0 )
|
||||
{
|
||||
if( buflen - len < 5 )
|
||||
return;
|
||||
|
||||
mbedtls_snprintf( buf + len, buflen - len, " : " );
|
||||
|
||||
buf += len + 3;
|
||||
buflen -= len + 3;
|
||||
}
|
||||
|
||||
// Translate low level error code.
|
||||
low_level_error_description = mbedtls_low_level_strerr( ret );
|
||||
|
||||
if( low_level_error_description == NULL )
|
||||
mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", (unsigned int) use_ret );
|
||||
else
|
||||
mbedtls_snprintf( buf, buflen, "%s", low_level_error_description );
|
||||
}
|
||||
|
||||
#else /* MBEDTLS_ERROR_C */
|
||||
|
||||
/*
|
||||
* Provide an non-function in case MBEDTLS_ERROR_C is not defined
|
||||
*/
|
||||
void mbedtls_strerror( int ret, char *buf, size_t buflen )
|
||||
{
|
||||
((void) ret);
|
||||
|
||||
if( buflen > 0 )
|
||||
buf[0] = '\0';
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_ERROR_C */
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
void (*mbedtls_test_hook_error_add)( int, int, const char *, int );
|
||||
#endif
|
||||
|
||||
#endif /* MBEDTLS_ERROR_C || MBEDTLS_ERROR_STRERROR_DUMMY */
|
@ -436,6 +436,9 @@ int mbedtls_hmac_drbg_write_seed_file( mbedtls_hmac_drbg_context *ctx, const cha
|
||||
if( ( f = fopen( path, "wb" ) ) == NULL )
|
||||
return( MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR );
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( f, NULL );
|
||||
|
||||
if( ( ret = mbedtls_hmac_drbg_random( ctx, buf, sizeof( buf ) ) ) != 0 )
|
||||
goto exit;
|
||||
|
||||
@ -465,6 +468,9 @@ int mbedtls_hmac_drbg_update_seed_file( mbedtls_hmac_drbg_context *ctx, const ch
|
||||
if( ( f = fopen( path, "rb" ) ) == NULL )
|
||||
return( MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR );
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( f, NULL );
|
||||
|
||||
n = fread( buf, 1, sizeof( buf ), f );
|
||||
if( fread( &c, 1, 1, f ) != 0 )
|
||||
{
|
||||
|
@ -605,6 +605,9 @@ int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path, unsigne
|
||||
if( ( f = fopen( path, "rb" ) ) == NULL )
|
||||
return( MBEDTLS_ERR_MD_FILE_IO_ERROR );
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( f, NULL );
|
||||
|
||||
mbedtls_md_init( &ctx );
|
||||
|
||||
if( ( ret = mbedtls_md_setup( &ctx, md_info, 0 ) ) != 0 )
|
||||
|
@ -82,6 +82,9 @@ int mbedtls_pk_load_file( const char *path, unsigned char **buf, size_t *n )
|
||||
if( ( f = fopen( path, "rb" ) ) == NULL )
|
||||
return( MBEDTLS_ERR_PK_FILE_IO_ERROR );
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( f, NULL );
|
||||
|
||||
fseek( f, 0, SEEK_END );
|
||||
if( ( size = ftell( f ) ) == -1 )
|
||||
{
|
||||
|
@ -226,6 +226,28 @@ int mbedtls_platform_set_fprintf( int (*fprintf_func)( FILE *, const char *, ...
|
||||
}
|
||||
#endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_SETBUF_ALT)
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_SETBUF)
|
||||
/*
|
||||
* Make dummy function to prevent NULL pointer dereferences
|
||||
*/
|
||||
static void platform_setbuf_uninit( FILE *stream, char *buf )
|
||||
{
|
||||
((void) stream);
|
||||
((void) buf);
|
||||
}
|
||||
|
||||
#define MBEDTLS_PLATFORM_STD_SETBUF platform_setbuf_uninit
|
||||
#endif /* !MBEDTLS_PLATFORM_STD_SETBUF */
|
||||
void (*mbedtls_setbuf)( FILE *stream, char *buf ) = MBEDTLS_PLATFORM_STD_SETBUF;
|
||||
|
||||
int mbedtls_platform_set_setbuf( void (*setbuf_func)( FILE *stream, char *buf ) )
|
||||
{
|
||||
mbedtls_setbuf = setbuf_func;
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_PLATFORM_SETBUF_ALT */
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_EXIT_ALT)
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_EXIT)
|
||||
/*
|
||||
@ -288,6 +310,9 @@ int mbedtls_platform_std_nv_seed_read( unsigned char *buf, size_t buf_len )
|
||||
if( ( file = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "rb" ) ) == NULL )
|
||||
return( -1 );
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( file, NULL );
|
||||
|
||||
if( ( n = fread( buf, 1, buf_len, file ) ) != buf_len )
|
||||
{
|
||||
fclose( file );
|
||||
@ -307,6 +332,9 @@ int mbedtls_platform_std_nv_seed_write( unsigned char *buf, size_t buf_len )
|
||||
if( ( file = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "w" ) ) == NULL )
|
||||
return -1;
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( file, NULL );
|
||||
|
||||
if( ( n = fwrite( buf, 1, buf_len, file ) ) != buf_len )
|
||||
{
|
||||
fclose( file );
|
||||
|
@ -102,6 +102,9 @@ static psa_status_t psa_its_read_file( psa_storage_uid_t uid,
|
||||
if( *p_stream == NULL )
|
||||
return( PSA_ERROR_DOES_NOT_EXIST );
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( *p_stream, NULL );
|
||||
|
||||
n = fread( &header, 1, sizeof( header ), *p_stream );
|
||||
if( n != sizeof( header ) )
|
||||
return( PSA_ERROR_DATA_CORRUPT );
|
||||
@ -201,9 +204,13 @@ psa_status_t psa_its_set( psa_storage_uid_t uid,
|
||||
|
||||
psa_its_fill_filename( uid, filename );
|
||||
stream = fopen( PSA_ITS_STORAGE_TEMP, "wb" );
|
||||
|
||||
if( stream == NULL )
|
||||
goto exit;
|
||||
|
||||
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
||||
mbedtls_setbuf( stream, NULL );
|
||||
|
||||
status = PSA_ERROR_INSUFFICIENT_STORAGE;
|
||||
n = fwrite( &header, 1, sizeof( header ), stream );
|
||||
if( n != sizeof( header ) )
|
||||
|
@ -50,6 +50,7 @@ void mbedtls_ssl_cache_init( mbedtls_ssl_cache_context *cache )
|
||||
#endif
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_cache_find_entry( mbedtls_ssl_cache_context *cache,
|
||||
unsigned char const *session_id,
|
||||
size_t session_id_len,
|
||||
@ -124,6 +125,7 @@ exit:
|
||||
return( ret );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_cache_pick_writing_slot( mbedtls_ssl_cache_context *cache,
|
||||
unsigned char const *session_id,
|
||||
size_t session_id_len,
|
||||
|
@ -1778,6 +1778,7 @@ const int *mbedtls_ssl_list_ciphersuites( void )
|
||||
static int supported_ciphersuites[MAX_CIPHERSUITES];
|
||||
static int supported_init = 0;
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ciphersuite_is_removed( const mbedtls_ssl_ciphersuite_t *cs_info )
|
||||
{
|
||||
(void)cs_info;
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "ssl_debug_helpers.h"
|
||||
|
||||
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_hostname_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -129,6 +130,7 @@ static int ssl_write_hostname_ext( mbedtls_ssl_context *ssl,
|
||||
* } ProtocolNameList;
|
||||
*
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_alpn_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -226,6 +228,7 @@ static int ssl_write_alpn_ext( mbedtls_ssl_context *ssl,
|
||||
*
|
||||
* DHE groups are not supported yet.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_supported_groups_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -308,6 +311,7 @@ static int ssl_write_supported_groups_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C ||
|
||||
MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_client_hello_cipher_suites(
|
||||
mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
@ -424,6 +428,7 @@ static int ssl_write_client_hello_cipher_suites(
|
||||
* };
|
||||
* } ClientHello;
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_client_hello_body( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
unsigned char *end,
|
||||
@ -654,6 +659,7 @@ static int ssl_write_client_hello_body( mbedtls_ssl_context *ssl,
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_generate_random( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -691,6 +697,7 @@ static int ssl_generate_random( mbedtls_ssl_context *ssl )
|
||||
return( ret );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_prepare_client_hello( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret;
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_write_client_hello( mbedtls_ssl_context *ssl );
|
||||
|
||||
#endif /* MBEDTLS_SSL_CLIENT_H */
|
||||
|
@ -160,6 +160,7 @@ int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx,
|
||||
/*
|
||||
* Generate the HMAC part of a cookie
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_cookie_hmac( mbedtls_md_context_t *hmac_ctx,
|
||||
const unsigned char time[4],
|
||||
unsigned char **p, unsigned char *end,
|
||||
|
221
library/ssl_debug_helpers_generated.c
Normal file
221
library/ssl_debug_helpers_generated.c
Normal file
@ -0,0 +1,221 @@
|
||||
/* Automatically generated by generate_ssl_debug_helpers.py. DO NOT EDIT. */
|
||||
|
||||
/**
|
||||
* \file ssl_debug_helpers_generated.c
|
||||
*
|
||||
* \brief Automatically generated helper functions for debugging
|
||||
*/
|
||||
/*
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#if defined(MBEDTLS_DEBUG_C)
|
||||
|
||||
#include "ssl_debug_helpers.h"
|
||||
|
||||
|
||||
const char *mbedtls_ssl_named_group_to_str( uint16_t in )
|
||||
{
|
||||
switch( in )
|
||||
{
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_SECP192K1:
|
||||
return "secp192k1";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_SECP192R1:
|
||||
return "secp192r1";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_SECP224K1:
|
||||
return "secp224k1";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_SECP224R1:
|
||||
return "secp224r1";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_SECP256K1:
|
||||
return "secp256k1";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1:
|
||||
return "secp256r1";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_SECP384R1:
|
||||
return "secp384r1";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_SECP521R1:
|
||||
return "secp521r1";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_BP256R1:
|
||||
return "bp256r1";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_BP384R1:
|
||||
return "bp384r1";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_BP512R1:
|
||||
return "bp512r1";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_X25519:
|
||||
return "x25519";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_X448:
|
||||
return "x448";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE2048:
|
||||
return "ffdhe2048";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE3072:
|
||||
return "ffdhe3072";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE4096:
|
||||
return "ffdhe4096";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE6144:
|
||||
return "ffdhe6144";
|
||||
case MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE8192:
|
||||
return "ffdhe8192";
|
||||
};
|
||||
|
||||
return "UNKOWN";
|
||||
}
|
||||
const char* mbedtls_ssl_sig_alg_to_str( uint16_t in )
|
||||
{
|
||||
switch( in )
|
||||
{
|
||||
case MBEDTLS_TLS1_3_SIG_RSA_PKCS1_SHA256:
|
||||
return "rsa_pkcs1_sha256";
|
||||
case MBEDTLS_TLS1_3_SIG_RSA_PKCS1_SHA384:
|
||||
return "rsa_pkcs1_sha384";
|
||||
case MBEDTLS_TLS1_3_SIG_RSA_PKCS1_SHA512:
|
||||
return "rsa_pkcs1_sha512";
|
||||
case MBEDTLS_TLS1_3_SIG_ECDSA_SECP256R1_SHA256:
|
||||
return "ecdsa_secp256r1_sha256";
|
||||
case MBEDTLS_TLS1_3_SIG_ECDSA_SECP384R1_SHA384:
|
||||
return "ecdsa_secp384r1_sha384";
|
||||
case MBEDTLS_TLS1_3_SIG_ECDSA_SECP521R1_SHA512:
|
||||
return "ecdsa_secp521r1_sha512";
|
||||
case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA256:
|
||||
return "rsa_pss_rsae_sha256";
|
||||
case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA384:
|
||||
return "rsa_pss_rsae_sha384";
|
||||
case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA512:
|
||||
return "rsa_pss_rsae_sha512";
|
||||
case MBEDTLS_TLS1_3_SIG_ED25519:
|
||||
return "ed25519";
|
||||
case MBEDTLS_TLS1_3_SIG_ED448:
|
||||
return "ed448";
|
||||
case MBEDTLS_TLS1_3_SIG_RSA_PSS_PSS_SHA256:
|
||||
return "rsa_pss_pss_sha256";
|
||||
case MBEDTLS_TLS1_3_SIG_RSA_PSS_PSS_SHA384:
|
||||
return "rsa_pss_pss_sha384";
|
||||
case MBEDTLS_TLS1_3_SIG_RSA_PSS_PSS_SHA512:
|
||||
return "rsa_pss_pss_sha512";
|
||||
case MBEDTLS_TLS1_3_SIG_RSA_PKCS1_SHA1:
|
||||
return "rsa_pkcs1_sha1";
|
||||
case MBEDTLS_TLS1_3_SIG_ECDSA_SHA1:
|
||||
return "ecdsa_sha1";
|
||||
case MBEDTLS_TLS1_3_SIG_NONE:
|
||||
return "none";
|
||||
};
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
const char *mbedtls_ssl_states_str( mbedtls_ssl_states in )
|
||||
{
|
||||
const char * in_to_str[]=
|
||||
{
|
||||
[MBEDTLS_SSL_HELLO_REQUEST] = "MBEDTLS_SSL_HELLO_REQUEST",
|
||||
[MBEDTLS_SSL_CLIENT_HELLO] = "MBEDTLS_SSL_CLIENT_HELLO",
|
||||
[MBEDTLS_SSL_SERVER_HELLO] = "MBEDTLS_SSL_SERVER_HELLO",
|
||||
[MBEDTLS_SSL_SERVER_CERTIFICATE] = "MBEDTLS_SSL_SERVER_CERTIFICATE",
|
||||
[MBEDTLS_SSL_SERVER_KEY_EXCHANGE] = "MBEDTLS_SSL_SERVER_KEY_EXCHANGE",
|
||||
[MBEDTLS_SSL_CERTIFICATE_REQUEST] = "MBEDTLS_SSL_CERTIFICATE_REQUEST",
|
||||
[MBEDTLS_SSL_SERVER_HELLO_DONE] = "MBEDTLS_SSL_SERVER_HELLO_DONE",
|
||||
[MBEDTLS_SSL_CLIENT_CERTIFICATE] = "MBEDTLS_SSL_CLIENT_CERTIFICATE",
|
||||
[MBEDTLS_SSL_CLIENT_KEY_EXCHANGE] = "MBEDTLS_SSL_CLIENT_KEY_EXCHANGE",
|
||||
[MBEDTLS_SSL_CERTIFICATE_VERIFY] = "MBEDTLS_SSL_CERTIFICATE_VERIFY",
|
||||
[MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC] = "MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC",
|
||||
[MBEDTLS_SSL_CLIENT_FINISHED] = "MBEDTLS_SSL_CLIENT_FINISHED",
|
||||
[MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC] = "MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC",
|
||||
[MBEDTLS_SSL_SERVER_FINISHED] = "MBEDTLS_SSL_SERVER_FINISHED",
|
||||
[MBEDTLS_SSL_FLUSH_BUFFERS] = "MBEDTLS_SSL_FLUSH_BUFFERS",
|
||||
[MBEDTLS_SSL_HANDSHAKE_WRAPUP] = "MBEDTLS_SSL_HANDSHAKE_WRAPUP",
|
||||
[MBEDTLS_SSL_HANDSHAKE_OVER] = "MBEDTLS_SSL_HANDSHAKE_OVER",
|
||||
[MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET] = "MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET",
|
||||
[MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT] = "MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT",
|
||||
[MBEDTLS_SSL_HELLO_RETRY_REQUEST] = "MBEDTLS_SSL_HELLO_RETRY_REQUEST",
|
||||
[MBEDTLS_SSL_ENCRYPTED_EXTENSIONS] = "MBEDTLS_SSL_ENCRYPTED_EXTENSIONS",
|
||||
[MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY] = "MBEDTLS_SSL_CLIENT_CERTIFICATE_VERIFY",
|
||||
[MBEDTLS_SSL_CLIENT_CCS_AFTER_SERVER_FINISHED] = "MBEDTLS_SSL_CLIENT_CCS_AFTER_SERVER_FINISHED",
|
||||
[MBEDTLS_SSL_CLIENT_CCS_BEFORE_2ND_CLIENT_HELLO] = "MBEDTLS_SSL_CLIENT_CCS_BEFORE_2ND_CLIENT_HELLO",
|
||||
[MBEDTLS_SSL_SERVER_CCS_AFTER_SERVER_HELLO] = "MBEDTLS_SSL_SERVER_CCS_AFTER_SERVER_HELLO",
|
||||
[MBEDTLS_SSL_SERVER_CCS_AFTER_HELLO_RETRY_REQUEST] = "MBEDTLS_SSL_SERVER_CCS_AFTER_HELLO_RETRY_REQUEST",
|
||||
};
|
||||
|
||||
if( in > ( sizeof( in_to_str )/sizeof( in_to_str[0]) - 1 ) ||
|
||||
in_to_str[ in ] == NULL )
|
||||
{
|
||||
return "UNKNOWN_VALUE";
|
||||
}
|
||||
return in_to_str[ in ];
|
||||
}
|
||||
|
||||
const char *mbedtls_ssl_protocol_version_str( mbedtls_ssl_protocol_version in )
|
||||
{
|
||||
const char * in_to_str[]=
|
||||
{
|
||||
[MBEDTLS_SSL_VERSION_UNKNOWN] = "MBEDTLS_SSL_VERSION_UNKNOWN",
|
||||
[MBEDTLS_SSL_VERSION_TLS1_2] = "MBEDTLS_SSL_VERSION_TLS1_2",
|
||||
[MBEDTLS_SSL_VERSION_TLS1_3] = "MBEDTLS_SSL_VERSION_TLS1_3",
|
||||
};
|
||||
|
||||
if( in > ( sizeof( in_to_str )/sizeof( in_to_str[0]) - 1 ) ||
|
||||
in_to_str[ in ] == NULL )
|
||||
{
|
||||
return "UNKNOWN_VALUE";
|
||||
}
|
||||
return in_to_str[ in ];
|
||||
}
|
||||
|
||||
const char *mbedtls_tls_prf_types_str( mbedtls_tls_prf_types in )
|
||||
{
|
||||
const char * in_to_str[]=
|
||||
{
|
||||
[MBEDTLS_SSL_TLS_PRF_NONE] = "MBEDTLS_SSL_TLS_PRF_NONE",
|
||||
[MBEDTLS_SSL_TLS_PRF_SHA384] = "MBEDTLS_SSL_TLS_PRF_SHA384",
|
||||
[MBEDTLS_SSL_TLS_PRF_SHA256] = "MBEDTLS_SSL_TLS_PRF_SHA256",
|
||||
[MBEDTLS_SSL_HKDF_EXPAND_SHA384] = "MBEDTLS_SSL_HKDF_EXPAND_SHA384",
|
||||
[MBEDTLS_SSL_HKDF_EXPAND_SHA256] = "MBEDTLS_SSL_HKDF_EXPAND_SHA256",
|
||||
};
|
||||
|
||||
if( in > ( sizeof( in_to_str )/sizeof( in_to_str[0]) - 1 ) ||
|
||||
in_to_str[ in ] == NULL )
|
||||
{
|
||||
return "UNKNOWN_VALUE";
|
||||
}
|
||||
return in_to_str[ in ];
|
||||
}
|
||||
|
||||
const char *mbedtls_ssl_key_export_type_str( mbedtls_ssl_key_export_type in )
|
||||
{
|
||||
const char * in_to_str[]=
|
||||
{
|
||||
[MBEDTLS_SSL_KEY_EXPORT_TLS12_MASTER_SECRET] = "MBEDTLS_SSL_KEY_EXPORT_TLS12_MASTER_SECRET",
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
|
||||
[MBEDTLS_SSL_KEY_EXPORT_TLS1_3_CLIENT_EARLY_SECRET] = "MBEDTLS_SSL_KEY_EXPORT_TLS1_3_CLIENT_EARLY_SECRET",
|
||||
[MBEDTLS_SSL_KEY_EXPORT_TLS1_3_EARLY_EXPORTER_SECRET] = "MBEDTLS_SSL_KEY_EXPORT_TLS1_3_EARLY_EXPORTER_SECRET",
|
||||
[MBEDTLS_SSL_KEY_EXPORT_TLS1_3_CLIENT_HANDSHAKE_TRAFFIC_SECRET] = "MBEDTLS_SSL_KEY_EXPORT_TLS1_3_CLIENT_HANDSHAKE_TRAFFIC_SECRET",
|
||||
[MBEDTLS_SSL_KEY_EXPORT_TLS1_3_SERVER_HANDSHAKE_TRAFFIC_SECRET] = "MBEDTLS_SSL_KEY_EXPORT_TLS1_3_SERVER_HANDSHAKE_TRAFFIC_SECRET",
|
||||
[MBEDTLS_SSL_KEY_EXPORT_TLS1_3_CLIENT_APPLICATION_TRAFFIC_SECRET] = "MBEDTLS_SSL_KEY_EXPORT_TLS1_3_CLIENT_APPLICATION_TRAFFIC_SECRET",
|
||||
[MBEDTLS_SSL_KEY_EXPORT_TLS1_3_SERVER_APPLICATION_TRAFFIC_SECRET] = "MBEDTLS_SSL_KEY_EXPORT_TLS1_3_SERVER_APPLICATION_TRAFFIC_SECRET",
|
||||
#endif
|
||||
};
|
||||
|
||||
if( in > ( sizeof( in_to_str )/sizeof( in_to_str[0]) - 1 ) ||
|
||||
in_to_str[ in ] == NULL )
|
||||
{
|
||||
return "UNKNOWN_VALUE";
|
||||
}
|
||||
return in_to_str[ in ];
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* MBEDTLS_DEBUG_C */
|
||||
/* End of automatically generated file. */
|
||||
|
@ -381,11 +381,38 @@ static inline size_t mbedtls_ssl_get_input_buflen( const mbedtls_ssl_context *ct
|
||||
* \return Zero if the needed space is available in the buffer, non-zero
|
||||
* otherwise.
|
||||
*/
|
||||
#if ! defined(MBEDTLS_TEST_HOOKS)
|
||||
static inline int mbedtls_ssl_chk_buf_ptr( const uint8_t *cur,
|
||||
const uint8_t *end, size_t need )
|
||||
{
|
||||
return( ( cur > end ) || ( need > (size_t)( end - cur ) ) );
|
||||
}
|
||||
#else
|
||||
typedef struct
|
||||
{
|
||||
const uint8_t *cur;
|
||||
const uint8_t *end;
|
||||
size_t need;
|
||||
} mbedtls_ssl_chk_buf_ptr_args;
|
||||
|
||||
void mbedtls_ssl_set_chk_buf_ptr_fail_args(
|
||||
const uint8_t *cur, const uint8_t *end, size_t need );
|
||||
void mbedtls_ssl_reset_chk_buf_ptr_fail_args( void );
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_cmp_chk_buf_ptr_fail_args( mbedtls_ssl_chk_buf_ptr_args *args );
|
||||
|
||||
static inline int mbedtls_ssl_chk_buf_ptr( const uint8_t *cur,
|
||||
const uint8_t *end, size_t need )
|
||||
{
|
||||
if( ( cur > end ) || ( need > (size_t)( end - cur ) ) )
|
||||
{
|
||||
mbedtls_ssl_set_chk_buf_ptr_fail_args( cur, end, need );
|
||||
return( 1 );
|
||||
}
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
|
||||
/**
|
||||
* \brief This macro checks if the remaining size in a buffer is
|
||||
@ -1102,6 +1129,7 @@ struct mbedtls_ssl_flight_item
|
||||
* (<> 0) or not ( 0 ).
|
||||
* \param[out] out_len Length of the data written into the buffer \p buf
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls12_write_client_hello_exts( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -1153,7 +1181,9 @@ void mbedtls_ssl_set_inbound_transform( mbedtls_ssl_context *ssl,
|
||||
void mbedtls_ssl_set_outbound_transform( mbedtls_ssl_context *ssl,
|
||||
mbedtls_ssl_transform *transform );
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl );
|
||||
void mbedtls_ssl_handshake_wrapup( mbedtls_ssl_context *ssl );
|
||||
static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context *ssl,
|
||||
@ -1162,15 +1192,19 @@ static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context *ssl,
|
||||
ssl->state = ( int ) state;
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_send_fatal_handshake_failure( mbedtls_ssl_context *ssl );
|
||||
|
||||
void mbedtls_ssl_reset_checksum( mbedtls_ssl_context *ssl );
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl );
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_handle_message_type( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl );
|
||||
void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl );
|
||||
|
||||
@ -1250,16 +1284,20 @@ void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl );
|
||||
* following the above definition.
|
||||
*
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl,
|
||||
unsigned update_hs_digest );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want );
|
||||
|
||||
/*
|
||||
* Write handshake message header
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_start_handshake_msg( mbedtls_ssl_context *ssl, unsigned hs_type,
|
||||
unsigned char **buf, size_t *buf_len );
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_write_handshake_msg_ext( mbedtls_ssl_context *ssl,
|
||||
int update_checksum,
|
||||
int force_flush );
|
||||
@ -1271,19 +1309,28 @@ static inline int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl )
|
||||
/*
|
||||
* Write handshake message tail
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_finish_handshake_msg( mbedtls_ssl_context *ssl,
|
||||
size_t buf_len, size_t msg_len );
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, int force_flush );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl );
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl );
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_write_change_cipher_spec( mbedtls_ssl_context *ssl );
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_parse_finished( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl );
|
||||
|
||||
void mbedtls_ssl_optimize_checksum( mbedtls_ssl_context *ssl,
|
||||
@ -1299,10 +1346,12 @@ void mbedtls_ssl_add_hs_msg_to_checksum( mbedtls_ssl_context *ssl,
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
|
||||
#if !defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl,
|
||||
mbedtls_key_exchange_type_t key_ex );
|
||||
#endif /* !MBEDTLS_USE_PSA_CRYPTO */
|
||||
#if defined(MBEDTLS_SSL_CLI_C) && defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_conf_has_static_psk( mbedtls_ssl_config const *conf );
|
||||
#endif
|
||||
|
||||
@ -1370,11 +1419,14 @@ mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash( unsigned char hash );
|
||||
unsigned char mbedtls_ssl_hash_from_md_alg( int md );
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md );
|
||||
#endif
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_check_curve_tls_id( const mbedtls_ssl_context *ssl, uint16_t tls_id );
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_check_curve( const mbedtls_ssl_context *ssl, mbedtls_ecp_group_id grp_id );
|
||||
#endif
|
||||
|
||||
@ -1429,6 +1481,7 @@ static inline mbedtls_x509_crt *mbedtls_ssl_own_cert( mbedtls_ssl_context *ssl )
|
||||
*
|
||||
* Return 0 if everything is OK, -1 if not.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_check_cert_usage( const mbedtls_x509_crt *cert,
|
||||
const mbedtls_ssl_ciphersuite_t *ciphersuite,
|
||||
int cert_endpoint,
|
||||
@ -1477,21 +1530,26 @@ static inline size_t mbedtls_ssl_hs_hdr_len( const mbedtls_ssl_context *ssl )
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
void mbedtls_ssl_send_flight_completed( mbedtls_ssl_context *ssl );
|
||||
void mbedtls_ssl_recv_flight_completed( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_resend( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_flight_transmit( mbedtls_ssl_context *ssl );
|
||||
#endif
|
||||
|
||||
/* Visible for testing purposes only */
|
||||
#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_dtls_replay_check( mbedtls_ssl_context const *ssl );
|
||||
void mbedtls_ssl_dtls_replay_update( mbedtls_ssl_context *ssl );
|
||||
#endif
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_session_copy( mbedtls_ssl_session *dst,
|
||||
const mbedtls_ssl_session *src );
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
/* The hash buffer must have at least MBEDTLS_MD_MAX_SIZE bytes of length. */
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_get_key_exchange_md_tls1_2( mbedtls_ssl_context *ssl,
|
||||
unsigned char *hash, size_t *hashlen,
|
||||
unsigned char *data, size_t data_len,
|
||||
@ -1503,11 +1561,13 @@ int mbedtls_ssl_get_key_exchange_md_tls1_2( mbedtls_ssl_context *ssl,
|
||||
#endif
|
||||
|
||||
void mbedtls_ssl_transform_init( mbedtls_ssl_transform *transform );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl,
|
||||
mbedtls_ssl_transform *transform,
|
||||
mbedtls_record *rec,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl,
|
||||
mbedtls_ssl_transform *transform,
|
||||
mbedtls_record *rec );
|
||||
@ -1525,10 +1585,12 @@ static inline size_t mbedtls_ssl_ep_len( const mbedtls_ssl_context *ssl )
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_resend_hello_request( mbedtls_ssl_context *ssl );
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
void mbedtls_ssl_set_timer( mbedtls_ssl_context *ssl, uint32_t millisecs );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_check_timer( mbedtls_ssl_context *ssl );
|
||||
|
||||
void mbedtls_ssl_reset_in_out_pointers( mbedtls_ssl_context *ssl );
|
||||
@ -1536,6 +1598,7 @@ void mbedtls_ssl_update_out_pointers( mbedtls_ssl_context *ssl,
|
||||
mbedtls_ssl_transform *transform );
|
||||
void mbedtls_ssl_update_in_pointers( mbedtls_ssl_context *ssl );
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial );
|
||||
void mbedtls_ssl_session_reset_msg_layer( mbedtls_ssl_context *ssl,
|
||||
int partial );
|
||||
@ -1543,6 +1606,7 @@ void mbedtls_ssl_session_reset_msg_layer( mbedtls_ssl_context *ssl,
|
||||
/*
|
||||
* Send pending alert
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_handle_pending_alert( mbedtls_ssl_context *ssl );
|
||||
|
||||
/*
|
||||
@ -1563,6 +1627,7 @@ void mbedtls_ssl_dtls_replay_reset( mbedtls_ssl_context *ssl );
|
||||
void mbedtls_ssl_handshake_wrapup_free_hs_transform( mbedtls_ssl_context *ssl );
|
||||
|
||||
#if defined(MBEDTLS_SSL_RENEGOTIATION)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_start_renegotiation( mbedtls_ssl_context *ssl );
|
||||
#endif /* MBEDTLS_SSL_RENEGOTIATION */
|
||||
|
||||
@ -1627,7 +1692,9 @@ static inline int mbedtls_ssl_conf_is_hybrid_tls12_tls13( const mbedtls_ssl_conf
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
|
||||
extern const uint8_t mbedtls_ssl_tls13_hello_retry_request_magic[
|
||||
MBEDTLS_SERVER_HELLO_RANDOM_LEN ];
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_write_finished_message( mbedtls_ssl_context *ssl );
|
||||
void mbedtls_ssl_tls13_handshake_wrapup( mbedtls_ssl_context *ssl );
|
||||
|
||||
@ -1640,6 +1707,7 @@ void mbedtls_ssl_tls13_handshake_wrapup( mbedtls_ssl_context *ssl );
|
||||
* \param[in] end End address of the buffer where to write the extensions
|
||||
* \param[out] out_len Length of the data written into the buffer \p buf
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_write_client_hello_exts( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
unsigned char *end,
|
||||
@ -1650,6 +1718,7 @@ int mbedtls_ssl_tls13_write_client_hello_exts( mbedtls_ssl_context *ssl,
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl );
|
||||
|
||||
/**
|
||||
@ -1657,6 +1726,7 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl );
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_handshake_server_step( mbedtls_ssl_context *ssl );
|
||||
|
||||
|
||||
@ -1749,6 +1819,7 @@ static inline int mbedtls_ssl_tls13_some_psk_enabled( mbedtls_ssl_context *ssl )
|
||||
/*
|
||||
* Fetch TLS 1.3 handshake message header
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_fetch_handshake_msg( mbedtls_ssl_context *ssl,
|
||||
unsigned hs_type,
|
||||
unsigned char **buf,
|
||||
@ -1757,17 +1828,20 @@ int mbedtls_ssl_tls13_fetch_handshake_msg( mbedtls_ssl_context *ssl,
|
||||
/*
|
||||
* Handler of TLS 1.3 server certificate message
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_process_certificate( mbedtls_ssl_context *ssl );
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
|
||||
/*
|
||||
* Handler of TLS 1.3 write Certificate message
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_write_certificate( mbedtls_ssl_context *ssl );
|
||||
|
||||
/*
|
||||
* Handler of TLS 1.3 write Certificate Verify message
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_write_certificate_verify( mbedtls_ssl_context *ssl );
|
||||
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */
|
||||
@ -1775,16 +1849,20 @@ int mbedtls_ssl_tls13_write_certificate_verify( mbedtls_ssl_context *ssl );
|
||||
/*
|
||||
* Generic handler of Certificate Verify
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_process_certificate_verify( mbedtls_ssl_context *ssl );
|
||||
|
||||
/*
|
||||
* Write of dummy-CCS's for middlebox compatibility
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_write_change_cipher_spec( mbedtls_ssl_context *ssl );
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_reset_transcript_for_hrr( mbedtls_ssl_context *ssl );
|
||||
|
||||
#if defined(MBEDTLS_ECDH_C)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_generate_and_write_ecdh_key_exchange(
|
||||
mbedtls_ssl_context *ssl,
|
||||
uint16_t named_group,
|
||||
@ -1800,12 +1878,14 @@ int mbedtls_ssl_tls13_generate_and_write_ecdh_key_exchange(
|
||||
/*
|
||||
* Parse TLS Signature Algorithm extension
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_parse_sig_alg_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
const unsigned char *end );
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */
|
||||
|
||||
/* Get handshake transcript */
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_get_handshake_transcript( mbedtls_ssl_context *ssl,
|
||||
const mbedtls_md_type_t md,
|
||||
unsigned char *dst,
|
||||
@ -2172,6 +2252,7 @@ static inline int mbedtls_ssl_sig_alg_is_supported(
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_check_sig_alg_cert_key_match( uint16_t sig_alg,
|
||||
mbedtls_pk_context *key );
|
||||
|
||||
@ -2265,6 +2346,7 @@ mbedtls_ssl_mode_t mbedtls_ssl_get_mode_from_ciphersuite(
|
||||
|
||||
#if defined(MBEDTLS_ECDH_C)
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_tls13_read_public_ecdhe_share( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
size_t buf_len );
|
||||
@ -2297,31 +2379,44 @@ static inline int mbedtls_ssl_tls13_cipher_suite_is_offered(
|
||||
*
|
||||
* \return 0 if valid, negative value otherwise.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_validate_ciphersuite(
|
||||
const mbedtls_ssl_context *ssl,
|
||||
const mbedtls_ssl_ciphersuite_t *suite_info,
|
||||
mbedtls_ssl_protocol_version min_tls_version,
|
||||
mbedtls_ssl_protocol_version max_tls_version );
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_write_sig_alg_ext( mbedtls_ssl_context *ssl, unsigned char *buf,
|
||||
const unsigned char *end, size_t *out_len );
|
||||
|
||||
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_parse_server_name_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
const unsigned char *end );
|
||||
#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */
|
||||
|
||||
#if defined(MBEDTLS_SSL_ALPN)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_parse_alpn_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
const unsigned char *end );
|
||||
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_write_alpn_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
unsigned char *end,
|
||||
size_t *out_len );
|
||||
#endif /* MBEDTLS_SSL_ALPN */
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
int mbedtls_ssl_check_dtls_clihlo_cookie(
|
||||
mbedtls_ssl_context *ssl,
|
||||
const unsigned char *cli_id, size_t cli_id_len,
|
||||
const unsigned char *in, size_t in_len,
|
||||
unsigned char *obuf, size_t buf_len, size_t *olen );
|
||||
#endif
|
||||
|
||||
#endif /* ssl_misc.h */
|
||||
|
@ -86,6 +86,7 @@ int mbedtls_ssl_check_timer( mbedtls_ssl_context *ssl )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_record_header( mbedtls_ssl_context const *ssl,
|
||||
unsigned char *buf,
|
||||
size_t len,
|
||||
@ -157,11 +158,16 @@ exit:
|
||||
static void ssl_buffering_free_slot( mbedtls_ssl_context *ssl,
|
||||
uint8_t slot );
|
||||
static void ssl_free_buffered_record( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_load_buffered_message( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_load_buffered_record( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_buffer_message( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_buffer_future_record( mbedtls_ssl_context *ssl,
|
||||
mbedtls_record const *rec );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_next_record_is_in_datagram( mbedtls_ssl_context *ssl );
|
||||
|
||||
static size_t ssl_get_maximum_datagram_size( mbedtls_ssl_context const *ssl )
|
||||
@ -179,6 +185,7 @@ static size_t ssl_get_maximum_datagram_size( mbedtls_ssl_context const *ssl )
|
||||
return( out_buf_len );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_get_remaining_space_in_datagram( mbedtls_ssl_context const *ssl )
|
||||
{
|
||||
size_t const bytes_written = ssl->out_left;
|
||||
@ -195,6 +202,7 @@ static int ssl_get_remaining_space_in_datagram( mbedtls_ssl_context const *ssl )
|
||||
return( (int) ( mtu - bytes_written ) );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_get_remaining_payload_in_datagram( mbedtls_ssl_context const *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -246,6 +254,7 @@ static int ssl_get_remaining_payload_in_datagram( mbedtls_ssl_context const *ssl
|
||||
* Double the retransmit timeout value, within the allowed range,
|
||||
* returning -1 if the maximum value has already been reached.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_double_retransmit_timeout( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
uint32_t new_timeout;
|
||||
@ -329,6 +338,7 @@ static size_t ssl_compute_padding_length( size_t len,
|
||||
* - A negative error code if `max_len` didn't offer enough space
|
||||
* for the expansion.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_build_inner_plaintext( unsigned char *content,
|
||||
size_t *content_size,
|
||||
size_t remaining,
|
||||
@ -356,6 +366,7 @@ static int ssl_build_inner_plaintext( unsigned char *content,
|
||||
|
||||
/* This function parses a (D)TLSInnerPlaintext structure.
|
||||
* See ssl_build_inner_plaintext() for details. */
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_inner_plaintext( unsigned char const *content,
|
||||
size_t *content_size,
|
||||
uint8_t *rec_type )
|
||||
@ -469,6 +480,7 @@ static void ssl_extract_add_data_from_record( unsigned char* add_data,
|
||||
#if defined(MBEDTLS_GCM_C) || \
|
||||
defined(MBEDTLS_CCM_C) || \
|
||||
defined(MBEDTLS_CHACHAPOLY_C)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_transform_aead_dynamic_iv_is_explicit(
|
||||
mbedtls_ssl_transform const *transform )
|
||||
{
|
||||
@ -2066,6 +2078,7 @@ int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl )
|
||||
/*
|
||||
* Append current handshake message to current outgoing flight
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_flight_append( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
mbedtls_ssl_flight_item *msg;
|
||||
@ -2132,6 +2145,7 @@ void mbedtls_ssl_flight_free( mbedtls_ssl_flight_item *flight )
|
||||
/*
|
||||
* Swap transform_out and out_ctr with the alternative ones
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_swap_epochs( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
mbedtls_ssl_transform *tmp_transform;
|
||||
@ -2767,6 +2781,7 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, int force_flush )
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_hs_is_proper_fragment( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
if( ssl->in_msglen < ssl->in_hslen ||
|
||||
@ -2792,6 +2807,7 @@ static uint32_t ssl_get_hs_frag_off( mbedtls_ssl_context const *ssl )
|
||||
ssl->in_msg[8] );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_check_hs_header( mbedtls_ssl_context const *ssl )
|
||||
{
|
||||
uint32_t msg_len, frag_off, frag_len;
|
||||
@ -2858,6 +2874,7 @@ static void ssl_bitmask_set( unsigned char *mask, size_t offset, size_t len )
|
||||
/*
|
||||
* Check that bitmask is full
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_bitmask_check( unsigned char *mask, size_t len )
|
||||
{
|
||||
size_t i;
|
||||
@ -3057,6 +3074,7 @@ static inline uint64_t ssl_load_six_bytes( unsigned char *buf )
|
||||
( (uint64_t) buf[5] ) );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int mbedtls_ssl_dtls_record_replay_check( mbedtls_ssl_context *ssl, uint8_t *record_in_ctr )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -3139,8 +3157,8 @@ void mbedtls_ssl_dtls_replay_update( mbedtls_ssl_context *ssl )
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && defined(MBEDTLS_SSL_SRV_C)
|
||||
/*
|
||||
* Without any SSL context, check if a datagram looks like a ClientHello with
|
||||
* a valid cookie, and if it doesn't, generate a HelloVerifyRequest message.
|
||||
* Check if a datagram looks like a ClientHello with a valid cookie,
|
||||
* and if it doesn't, generate a HelloVerifyRequest message.
|
||||
* Both input and output include full DTLS headers.
|
||||
*
|
||||
* - if cookie is valid, return 0
|
||||
@ -3149,15 +3167,15 @@ void mbedtls_ssl_dtls_replay_update( mbedtls_ssl_context *ssl )
|
||||
* return MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED
|
||||
* - otherwise return a specific error code
|
||||
*/
|
||||
static int ssl_check_dtls_clihlo_cookie(
|
||||
mbedtls_ssl_cookie_write_t *f_cookie_write,
|
||||
mbedtls_ssl_cookie_check_t *f_cookie_check,
|
||||
void *p_cookie,
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
MBEDTLS_STATIC_TESTABLE
|
||||
int mbedtls_ssl_check_dtls_clihlo_cookie(
|
||||
mbedtls_ssl_context *ssl,
|
||||
const unsigned char *cli_id, size_t cli_id_len,
|
||||
const unsigned char *in, size_t in_len,
|
||||
unsigned char *obuf, size_t buf_len, size_t *olen )
|
||||
{
|
||||
size_t sid_len, cookie_len;
|
||||
size_t sid_len, cookie_len, epoch, fragment_offset;
|
||||
unsigned char *p;
|
||||
|
||||
/*
|
||||
@ -3186,26 +3204,55 @@ static int ssl_check_dtls_clihlo_cookie(
|
||||
*
|
||||
* Minimum length is 61 bytes.
|
||||
*/
|
||||
if( in_len < 61 ||
|
||||
in[0] != MBEDTLS_SSL_MSG_HANDSHAKE ||
|
||||
in[3] != 0 || in[4] != 0 ||
|
||||
in[19] != 0 || in[20] != 0 || in[21] != 0 )
|
||||
MBEDTLS_SSL_DEBUG_MSG( 4, ( "check cookie: in_len=%u",
|
||||
(unsigned) in_len ) );
|
||||
MBEDTLS_SSL_DEBUG_BUF( 4, "cli_id", cli_id, cli_id_len );
|
||||
if( in_len < 61 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 4, ( "check cookie: record too short" ) );
|
||||
return( MBEDTLS_ERR_SSL_DECODE_ERROR );
|
||||
}
|
||||
|
||||
epoch = MBEDTLS_GET_UINT16_BE( in, 3 );
|
||||
fragment_offset = MBEDTLS_GET_UINT24_BE( in, 19 );
|
||||
|
||||
if( in[0] != MBEDTLS_SSL_MSG_HANDSHAKE || epoch != 0 ||
|
||||
fragment_offset != 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 4, ( "check cookie: not a good ClientHello" ) );
|
||||
MBEDTLS_SSL_DEBUG_MSG( 4, ( " type=%u epoch=%u fragment_offset=%u",
|
||||
in[0], (unsigned) epoch,
|
||||
(unsigned) fragment_offset ) );
|
||||
return( MBEDTLS_ERR_SSL_DECODE_ERROR );
|
||||
}
|
||||
|
||||
sid_len = in[59];
|
||||
if( sid_len > in_len - 61 )
|
||||
if( 59 + 1 + sid_len + 1 > in_len )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 4, ( "check cookie: sid_len=%u > %u",
|
||||
(unsigned) sid_len,
|
||||
(unsigned) in_len - 61 ) );
|
||||
return( MBEDTLS_ERR_SSL_DECODE_ERROR );
|
||||
}
|
||||
MBEDTLS_SSL_DEBUG_BUF( 4, "sid received from network",
|
||||
in + 60, sid_len );
|
||||
|
||||
cookie_len = in[60 + sid_len];
|
||||
if( cookie_len > in_len - 60 )
|
||||
return( MBEDTLS_ERR_SSL_DECODE_ERROR );
|
||||
|
||||
if( f_cookie_check( p_cookie, in + sid_len + 61, cookie_len,
|
||||
cli_id, cli_id_len ) == 0 )
|
||||
if( 59 + 1 + sid_len + 1 + cookie_len > in_len )
|
||||
{
|
||||
/* Valid cookie */
|
||||
MBEDTLS_SSL_DEBUG_MSG( 4, ( "check cookie: cookie_len=%u > %u",
|
||||
(unsigned) cookie_len,
|
||||
(unsigned) ( in_len - sid_len - 61 ) ) );
|
||||
return( MBEDTLS_ERR_SSL_DECODE_ERROR );
|
||||
}
|
||||
|
||||
MBEDTLS_SSL_DEBUG_BUF( 4, "cookie received from network",
|
||||
in + sid_len + 61, cookie_len );
|
||||
if( ssl->conf->f_cookie_check( ssl->conf->p_cookie,
|
||||
in + sid_len + 61, cookie_len,
|
||||
cli_id, cli_id_len ) == 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 4, ( "check cookie: valid" ) );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
@ -3240,8 +3287,9 @@ static int ssl_check_dtls_clihlo_cookie(
|
||||
|
||||
/* Generate and write actual cookie */
|
||||
p = obuf + 28;
|
||||
if( f_cookie_write( p_cookie,
|
||||
&p, obuf + buf_len, cli_id, cli_id_len ) != 0 )
|
||||
if( ssl->conf->f_cookie_write( ssl->conf->p_cookie,
|
||||
&p, obuf + buf_len,
|
||||
cli_id, cli_id_len ) != 0 )
|
||||
{
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
@ -3280,6 +3328,7 @@ static int ssl_check_dtls_clihlo_cookie(
|
||||
* includes the case of MBEDTLS_ERR_SSL_CLIENT_RECONNECT and of unexpected
|
||||
* errors, and is the right thing to do in both cases).
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_handle_possible_reconnect( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -3295,15 +3344,13 @@ static int ssl_handle_possible_reconnect( mbedtls_ssl_context *ssl )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
ret = ssl_check_dtls_clihlo_cookie(
|
||||
ssl->conf->f_cookie_write,
|
||||
ssl->conf->f_cookie_check,
|
||||
ssl->conf->p_cookie,
|
||||
ret = mbedtls_ssl_check_dtls_clihlo_cookie(
|
||||
ssl,
|
||||
ssl->cli_id, ssl->cli_id_len,
|
||||
ssl->in_buf, ssl->in_left,
|
||||
ssl->out_buf, MBEDTLS_SSL_OUT_CONTENT_LEN, &len );
|
||||
|
||||
MBEDTLS_SSL_DEBUG_RET( 2, "ssl_check_dtls_clihlo_cookie", ret );
|
||||
MBEDTLS_SSL_DEBUG_RET( 2, "mbedtls_ssl_check_dtls_clihlo_cookie", ret );
|
||||
|
||||
if( ret == MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED )
|
||||
{
|
||||
@ -3337,6 +3384,7 @@ static int ssl_handle_possible_reconnect( mbedtls_ssl_context *ssl )
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE && MBEDTLS_SSL_SRV_C */
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_check_record_type( uint8_t record_type )
|
||||
{
|
||||
if( record_type != MBEDTLS_SSL_MSG_HANDSHAKE &&
|
||||
@ -3369,6 +3417,7 @@ static int ssl_check_record_type( uint8_t record_type )
|
||||
* Point 2 is needed when the peer is resending, and we have already received
|
||||
* the first record from a datagram but are still waiting for the others.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_record_header( mbedtls_ssl_context const *ssl,
|
||||
unsigned char *buf,
|
||||
size_t len,
|
||||
@ -3481,7 +3530,6 @@ static int ssl_parse_record_header( mbedtls_ssl_context const *ssl,
|
||||
/*
|
||||
* Parse and validate record version
|
||||
*/
|
||||
|
||||
rec->ver[0] = buf[ rec_hdr_version_offset + 0 ];
|
||||
rec->ver[1] = buf[ rec_hdr_version_offset + 1 ];
|
||||
tls_version = mbedtls_ssl_read_version( buf + rec_hdr_version_offset,
|
||||
@ -3489,10 +3537,12 @@ static int ssl_parse_record_header( mbedtls_ssl_context const *ssl,
|
||||
|
||||
if( tls_version > ssl->conf->max_tls_version )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "TLS version mismatch" ) );
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "TLS version mismatch: got %u, expected max %u",
|
||||
(unsigned) tls_version,
|
||||
(unsigned) ssl->conf->max_tls_version) );
|
||||
|
||||
return( MBEDTLS_ERR_SSL_INVALID_RECORD );
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse/Copy record sequence number.
|
||||
*/
|
||||
@ -3594,6 +3644,7 @@ static int ssl_parse_record_header( mbedtls_ssl_context const *ssl,
|
||||
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && defined(MBEDTLS_SSL_SRV_C)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_check_client_reconnect( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
unsigned int rec_epoch = ( ssl->in_ctr[0] << 8 ) | ssl->in_ctr[1];
|
||||
@ -3623,6 +3674,7 @@ static int ssl_check_client_reconnect( mbedtls_ssl_context *ssl )
|
||||
/*
|
||||
* If applicable, decrypt record content
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_prepare_record_content( mbedtls_ssl_context *ssl,
|
||||
mbedtls_record *rec )
|
||||
{
|
||||
@ -3757,7 +3809,7 @@ static int ssl_prepare_record_content( mbedtls_ssl_context *ssl,
|
||||
|
||||
/* Check actual (decrypted) record content length against
|
||||
* configured maximum. */
|
||||
if( ssl->in_msglen > MBEDTLS_SSL_IN_CONTENT_LEN )
|
||||
if( rec->data_len > MBEDTLS_SSL_IN_CONTENT_LEN )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) );
|
||||
return( MBEDTLS_ERR_SSL_INVALID_RECORD );
|
||||
@ -3775,8 +3827,11 @@ static int ssl_prepare_record_content( mbedtls_ssl_context *ssl,
|
||||
*/
|
||||
|
||||
/* Helper functions for mbedtls_ssl_read_record(). */
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_consume_current_message( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_get_next_record( mbedtls_ssl_context *ssl );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_record_is_in_progress( mbedtls_ssl_context *ssl );
|
||||
|
||||
int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl,
|
||||
@ -3864,6 +3919,7 @@ int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl,
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_next_record_is_in_datagram( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
if( ssl->in_left > ssl->next_record_offset )
|
||||
@ -3872,6 +3928,7 @@ static int ssl_next_record_is_in_datagram( mbedtls_ssl_context *ssl )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_load_buffered_message( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
mbedtls_ssl_handshake_params * const hs = ssl->handshake;
|
||||
@ -3969,6 +4026,7 @@ exit:
|
||||
return( ret );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_buffer_make_space( mbedtls_ssl_context *ssl,
|
||||
size_t desired )
|
||||
{
|
||||
@ -4011,6 +4069,7 @@ static int ssl_buffer_make_space( mbedtls_ssl_context *ssl,
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_buffer_message( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = 0;
|
||||
@ -4215,6 +4274,7 @@ exit:
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_consume_current_message( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
/*
|
||||
@ -4302,6 +4362,7 @@ static int ssl_consume_current_message( mbedtls_ssl_context *ssl )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_record_is_in_progress( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
if( ssl->in_msglen > 0 )
|
||||
@ -4328,6 +4389,7 @@ static void ssl_free_buffered_record( mbedtls_ssl_context *ssl )
|
||||
}
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_load_buffered_record( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
mbedtls_ssl_handshake_params * const hs = ssl->handshake;
|
||||
@ -4385,6 +4447,7 @@ exit:
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_buffer_future_record( mbedtls_ssl_context *ssl,
|
||||
mbedtls_record const *rec )
|
||||
{
|
||||
@ -4443,6 +4506,7 @@ static int ssl_buffer_future_record( mbedtls_ssl_context *ssl,
|
||||
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_get_next_record( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -5193,6 +5257,7 @@ int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl )
|
||||
/*
|
||||
* Check record counters and renegotiate if they're above the limit.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_check_ctr_renegotiate( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
size_t ep_len = mbedtls_ssl_ep_len( ssl );
|
||||
@ -5232,6 +5297,7 @@ static int ssl_check_ctr_renegotiate( mbedtls_ssl_context *ssl )
|
||||
* and having a helper function allows to distinguish between TLS <= 1.2 and
|
||||
* TLS 1.3 in the future without bloating the logic of mbedtls_ssl_read().
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_handle_hs_message_post_handshake( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -5549,6 +5615,7 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len )
|
||||
* Therefore, it is possible that the input message length is 0 and the
|
||||
* corresponding return code is 0 on success.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_real( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf, size_t len )
|
||||
{
|
||||
|
@ -66,6 +66,7 @@ void mbedtls_ssl_ticket_init( mbedtls_ssl_ticket_context *ctx )
|
||||
/*
|
||||
* Generate/update a key
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_ticket_gen_key( mbedtls_ssl_ticket_context *ctx,
|
||||
unsigned char index )
|
||||
{
|
||||
@ -113,6 +114,7 @@ static int ssl_ticket_gen_key( mbedtls_ssl_ticket_context *ctx,
|
||||
/*
|
||||
* Rotate/generate keys if necessary
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_ticket_update_keys( mbedtls_ssl_ticket_context *ctx )
|
||||
{
|
||||
#if !defined(MBEDTLS_HAVE_TIME)
|
||||
|
@ -58,6 +58,30 @@
|
||||
#include "mbedtls/oid.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
static mbedtls_ssl_chk_buf_ptr_args chk_buf_ptr_fail_args;
|
||||
|
||||
void mbedtls_ssl_set_chk_buf_ptr_fail_args(
|
||||
const uint8_t *cur, const uint8_t *end, size_t need )
|
||||
{
|
||||
chk_buf_ptr_fail_args.cur = cur;
|
||||
chk_buf_ptr_fail_args.end = end;
|
||||
chk_buf_ptr_fail_args.need = need;
|
||||
}
|
||||
|
||||
void mbedtls_ssl_reset_chk_buf_ptr_fail_args( void )
|
||||
{
|
||||
memset( &chk_buf_ptr_fail_args, 0, sizeof( chk_buf_ptr_fail_args ) );
|
||||
}
|
||||
|
||||
int mbedtls_ssl_cmp_chk_buf_ptr_fail_args( mbedtls_ssl_chk_buf_ptr_args *args )
|
||||
{
|
||||
return( ( chk_buf_ptr_fail_args.cur != args->cur ) ||
|
||||
( chk_buf_ptr_fail_args.end != args->end ) ||
|
||||
( chk_buf_ptr_fail_args.need != args->need ) );
|
||||
}
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
|
||||
@ -275,6 +299,7 @@ int mbedtls_ssl_session_copy( mbedtls_ssl_session *dst,
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int resize_buffer( unsigned char **buffer, size_t len_new, size_t *len_old )
|
||||
{
|
||||
unsigned char* resized_buffer = mbedtls_calloc( 1, len_new );
|
||||
@ -380,6 +405,7 @@ typedef int ssl_tls_prf_t(const unsigned char *, size_t, const char *,
|
||||
const unsigned char *, size_t,
|
||||
unsigned char *, size_t);
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform,
|
||||
int ciphersuite,
|
||||
const unsigned char master[48],
|
||||
@ -393,6 +419,7 @@ static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform,
|
||||
const mbedtls_ssl_context *ssl );
|
||||
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int tls_prf_sha256( const unsigned char *secret, size_t slen,
|
||||
const char *label,
|
||||
const unsigned char *random, size_t rlen,
|
||||
@ -403,6 +430,7 @@ static void ssl_calc_finished_tls_sha256( mbedtls_ssl_context *,unsigned char *,
|
||||
#endif /* MBEDTLS_SHA256_C */
|
||||
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int tls_prf_sha384( const unsigned char *secret, size_t slen,
|
||||
const char *label,
|
||||
const unsigned char *random, size_t rlen,
|
||||
@ -415,6 +443,7 @@ static void ssl_calc_finished_tls_sha384( mbedtls_ssl_context *, unsigned char *
|
||||
static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session,
|
||||
unsigned char *buf,
|
||||
size_t buf_len );
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_session_load_tls12( mbedtls_ssl_session *session,
|
||||
const unsigned char *buf,
|
||||
size_t len );
|
||||
@ -672,6 +701,7 @@ void mbedtls_ssl_session_init( mbedtls_ssl_session *session )
|
||||
memset( session, 0, sizeof(mbedtls_ssl_session) );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_handshake_init( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
/* Clear old handshake information if present */
|
||||
@ -862,6 +892,7 @@ static int ssl_handshake_init( mbedtls_ssl_context *ssl )
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
|
||||
/* Dummy cookie callbacks for defaults */
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_cookie_write_dummy( void *ctx,
|
||||
unsigned char **p, unsigned char *end,
|
||||
const unsigned char *cli_id, size_t cli_id_len )
|
||||
@ -875,6 +906,7 @@ static int ssl_cookie_write_dummy( void *ctx,
|
||||
return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_cookie_check_dummy( void *ctx,
|
||||
const unsigned char *cookie, size_t cookie_len,
|
||||
const unsigned char *cli_id, size_t cli_id_len )
|
||||
@ -897,6 +929,7 @@ void mbedtls_ssl_init( mbedtls_ssl_context *ssl )
|
||||
memset( ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_conf_version_check( const mbedtls_ssl_context *ssl )
|
||||
{
|
||||
const mbedtls_ssl_config *conf = ssl->conf;
|
||||
@ -948,6 +981,7 @@ static int ssl_conf_version_check( const mbedtls_ssl_context *ssl )
|
||||
return( MBEDTLS_ERR_SSL_BAD_CONFIG );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_conf_check(const mbedtls_ssl_context *ssl)
|
||||
{
|
||||
int ret;
|
||||
@ -1092,6 +1126,8 @@ void mbedtls_ssl_session_reset_msg_layer( mbedtls_ssl_context *ssl,
|
||||
memset( ssl->in_buf, 0, in_buf_len );
|
||||
}
|
||||
|
||||
ssl->send_alert = 0;
|
||||
|
||||
/* Reset outgoing message writing */
|
||||
ssl->out_msgtype = 0;
|
||||
ssl->out_msglen = 0;
|
||||
@ -1371,6 +1407,7 @@ static void ssl_key_cert_free( mbedtls_ssl_key_cert *key_cert )
|
||||
}
|
||||
|
||||
/* Append a new keycert entry to a (possibly empty) list */
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_append_key_cert( mbedtls_ssl_key_cert **head,
|
||||
mbedtls_x509_crt *cert,
|
||||
mbedtls_pk_context *key )
|
||||
@ -1524,6 +1561,7 @@ int mbedtls_ssl_set_hs_ecjpake_password( mbedtls_ssl_context *ssl,
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_conf_psk_is_configured( mbedtls_ssl_config const *conf )
|
||||
{
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
@ -1569,6 +1607,7 @@ static void ssl_conf_remove_psk( mbedtls_ssl_config *conf )
|
||||
* It checks that the provided identity is well-formed and attempts
|
||||
* to make a copy of it in the SSL config.
|
||||
* On failure, the PSK identity in the config remains unset. */
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_conf_set_psk_identity( mbedtls_ssl_config *conf,
|
||||
unsigned char const *psk_identity,
|
||||
size_t psk_identity_len )
|
||||
@ -2763,6 +2802,7 @@ static unsigned char ssl_serialized_session_header[] = {
|
||||
*
|
||||
*/
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_session_save( const mbedtls_ssl_session *session,
|
||||
unsigned char omit_header,
|
||||
unsigned char *buf,
|
||||
@ -2837,6 +2877,7 @@ int mbedtls_ssl_session_save( const mbedtls_ssl_session *session,
|
||||
* This internal version is wrapped by a public function that cleans up in
|
||||
* case of error, and has an extra option omit_header.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_session_load( mbedtls_ssl_session *session,
|
||||
unsigned char omit_header,
|
||||
const unsigned char *buf,
|
||||
@ -2903,6 +2944,7 @@ int mbedtls_ssl_session_load( mbedtls_ssl_session *session,
|
||||
/*
|
||||
* Perform a single step of the SSL handshake
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_prepare_handshake_step( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -3061,6 +3103,7 @@ int mbedtls_ssl_handshake( mbedtls_ssl_context *ssl )
|
||||
/*
|
||||
* Write HelloRequest to request renegotiation on server
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_hello_request( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -3659,6 +3702,7 @@ int mbedtls_ssl_context_save( mbedtls_ssl_context *ssl,
|
||||
* This internal version is wrapped by a public function that cleans up in
|
||||
* case of error.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_context_load( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
size_t len )
|
||||
@ -4224,6 +4268,7 @@ static uint16_t ssl_preset_suiteb_groups[] = {
|
||||
#if defined(MBEDTLS_DEBUG_C) && defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
|
||||
/* Function for checking `ssl_preset_*_sig_algs` and `ssl_tls12_preset_*_sig_algs`
|
||||
* to make sure there are no duplicated signature algorithm entries. */
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_check_no_sig_alg_duplication( uint16_t * sig_algs )
|
||||
{
|
||||
size_t i, j;
|
||||
@ -4769,6 +4814,7 @@ exit:
|
||||
#else /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_get_handshake_transcript_sha384( mbedtls_ssl_context *ssl,
|
||||
unsigned char *dst,
|
||||
size_t dst_len,
|
||||
@ -4799,6 +4845,7 @@ exit:
|
||||
#endif /* MBEDTLS_SHA384_C */
|
||||
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_get_handshake_transcript_sha256( mbedtls_ssl_context *ssl,
|
||||
unsigned char *dst,
|
||||
size_t dst_len,
|
||||
@ -5034,6 +5081,7 @@ static psa_status_t setup_psa_key_derivation( psa_key_derivation_operation_t* de
|
||||
return( PSA_SUCCESS );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int tls_prf_generic( mbedtls_md_type_t md_type,
|
||||
const unsigned char *secret, size_t slen,
|
||||
const char *label,
|
||||
@ -5110,6 +5158,7 @@ static int tls_prf_generic( mbedtls_md_type_t md_type,
|
||||
|
||||
#else /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int tls_prf_generic( mbedtls_md_type_t md_type,
|
||||
const unsigned char *secret, size_t slen,
|
||||
const char *label,
|
||||
@ -5202,6 +5251,7 @@ exit:
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int tls_prf_sha256( const unsigned char *secret, size_t slen,
|
||||
const char *label,
|
||||
const unsigned char *random, size_t rlen,
|
||||
@ -5213,6 +5263,7 @@ static int tls_prf_sha256( const unsigned char *secret, size_t slen,
|
||||
#endif /* MBEDTLS_SHA256_C */
|
||||
|
||||
#if defined(MBEDTLS_SHA384_C)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int tls_prf_sha384( const unsigned char *secret, size_t slen,
|
||||
const char *label,
|
||||
const unsigned char *random, size_t rlen,
|
||||
@ -5232,6 +5283,7 @@ static int tls_prf_sha384( const unsigned char *secret, size_t slen,
|
||||
* Outputs:
|
||||
* - the tls_prf, calc_verify and calc_finished members of handshake structure
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_set_handshake_prfs( mbedtls_ssl_handshake_params *handshake,
|
||||
mbedtls_md_type_t hash )
|
||||
{
|
||||
@ -5276,6 +5328,7 @@ static int ssl_set_handshake_prfs( mbedtls_ssl_handshake_params *handshake,
|
||||
* EMS: passed to calc_verify (debug + session_negotiate)
|
||||
* PSA-PSA: conf
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_compute_master( mbedtls_ssl_handshake_params *handshake,
|
||||
unsigned char *master,
|
||||
const mbedtls_ssl_context *ssl )
|
||||
@ -5744,6 +5797,7 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch
|
||||
#endif /* !MBEDTLS_USE_PSA_CRYPTO && MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_SSL_RENEGOTIATION)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_hello_request( mbedtls_ssl_context *ssl );
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
@ -5915,6 +5969,7 @@ int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl )
|
||||
#if defined(MBEDTLS_SSL_RENEGOTIATION) && defined(MBEDTLS_SSL_CLI_C)
|
||||
|
||||
#if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_check_peer_crt_unchanged( mbedtls_ssl_context *ssl,
|
||||
unsigned char *crt_buf,
|
||||
size_t crt_buf_len )
|
||||
@ -5930,6 +5985,7 @@ static int ssl_check_peer_crt_unchanged( mbedtls_ssl_context *ssl,
|
||||
return( memcmp( peer_crt->raw.p, crt_buf, peer_crt->raw.len ) );
|
||||
}
|
||||
#else /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_check_peer_crt_unchanged( mbedtls_ssl_context *ssl,
|
||||
unsigned char *crt_buf,
|
||||
size_t crt_buf_len )
|
||||
@ -5964,6 +6020,7 @@ static int ssl_check_peer_crt_unchanged( mbedtls_ssl_context *ssl,
|
||||
* Once the certificate message is read, parse it into a cert chain and
|
||||
* perform basic checks, but leave actual verification to the caller
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_certificate_chain( mbedtls_ssl_context *ssl,
|
||||
mbedtls_x509_crt *chain )
|
||||
{
|
||||
@ -6119,6 +6176,7 @@ static int ssl_parse_certificate_chain( mbedtls_ssl_context *ssl,
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_SRV_C)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_srv_check_client_no_crt_notification( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT )
|
||||
@ -6144,6 +6202,7 @@ static int ssl_srv_check_client_no_crt_notification( mbedtls_ssl_context *ssl )
|
||||
*/
|
||||
#define SSL_CERTIFICATE_EXPECTED 0
|
||||
#define SSL_CERTIFICATE_SKIP 1
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_certificate_coordinate( mbedtls_ssl_context *ssl,
|
||||
int authmode )
|
||||
{
|
||||
@ -6173,6 +6232,7 @@ static int ssl_parse_certificate_coordinate( mbedtls_ssl_context *ssl,
|
||||
return( SSL_CERTIFICATE_EXPECTED );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl,
|
||||
int authmode,
|
||||
mbedtls_x509_crt *chain,
|
||||
@ -6270,7 +6330,9 @@ static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl,
|
||||
{
|
||||
const mbedtls_pk_context *pk = &chain->pk;
|
||||
|
||||
/* If certificate uses an EC key, make sure the curve is OK */
|
||||
/* If certificate uses an EC key, make sure the curve is OK.
|
||||
* This is a public key, so it can't be opaque, so can_do() is a good
|
||||
* enough check to ensure pk_ec() is safe to use here. */
|
||||
if( mbedtls_pk_can_do( pk, MBEDTLS_PK_ECKEY ) &&
|
||||
mbedtls_ssl_check_curve( ssl, mbedtls_pk_ec( *pk )->grp.id ) != 0 )
|
||||
{
|
||||
@ -6361,6 +6423,7 @@ static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl,
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_remember_peer_crt_digest( mbedtls_ssl_context *ssl,
|
||||
unsigned char *start, size_t len )
|
||||
{
|
||||
@ -6392,6 +6455,7 @@ static int ssl_remember_peer_crt_digest( mbedtls_ssl_context *ssl,
|
||||
return( ret );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_remember_peer_pubkey( mbedtls_ssl_context *ssl,
|
||||
unsigned char *start, size_t len )
|
||||
{
|
||||
@ -7060,6 +7124,7 @@ static mbedtls_tls_prf_types tls_prf_get_type( mbedtls_ssl_tls_prf_cb *tls_prf )
|
||||
* [in] optionally used for:
|
||||
* - MBEDTLS_DEBUG_C: ssl->conf->{f,p}_dbg
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_tls12_populate_transform( mbedtls_ssl_transform *transform,
|
||||
int ciphersuite,
|
||||
const unsigned char master[48],
|
||||
@ -7889,6 +7954,7 @@ static size_t ssl_session_save_tls12( const mbedtls_ssl_session *session,
|
||||
return( used );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_session_load_tls12( mbedtls_ssl_session *session,
|
||||
const unsigned char *buf,
|
||||
size_t len )
|
||||
@ -8254,6 +8320,7 @@ int mbedtls_ssl_write_sig_alg_ext( mbedtls_ssl_context *ssl, unsigned char *buf,
|
||||
* ServerName server_name_list<1..2^16-1>
|
||||
* } ServerNameList;
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_parse_server_name_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
const unsigned char *end )
|
||||
@ -8309,6 +8376,7 @@ int mbedtls_ssl_parse_server_name_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */
|
||||
|
||||
#if defined(MBEDTLS_SSL_ALPN)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
int mbedtls_ssl_parse_alpn_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
const unsigned char *end )
|
||||
|
@ -75,6 +75,7 @@ int mbedtls_ssl_conf_has_static_psk( mbedtls_ssl_config const *conf )
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_SSL_RENEGOTIATION)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_renegotiation_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -116,6 +117,7 @@ static int ssl_write_renegotiation_ext( mbedtls_ssl_context *ssl,
|
||||
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -147,6 +149,7 @@ static int ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl,
|
||||
MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -220,6 +223,7 @@ static int ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_cid_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -266,6 +270,7 @@ static int ssl_write_cid_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
|
||||
|
||||
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -298,6 +303,7 @@ static int ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
|
||||
|
||||
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_encrypt_then_mac_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -328,6 +334,7 @@ static int ssl_write_encrypt_then_mac_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
|
||||
|
||||
#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_extended_ms_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -358,6 +365,7 @@ static int ssl_write_extended_ms_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_session_ticket_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -400,6 +408,7 @@ static int ssl_write_session_ticket_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_SRTP)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf,
|
||||
const unsigned char *end,
|
||||
@ -629,6 +638,7 @@ int mbedtls_ssl_tls12_write_client_hello_exts( mbedtls_ssl_context *ssl,
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_renegotiation_info( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
size_t len )
|
||||
@ -673,6 +683,7 @@ static int ssl_parse_renegotiation_info( mbedtls_ssl_context *ssl,
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_max_fragment_length_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
size_t len )
|
||||
@ -699,6 +710,7 @@ static int ssl_parse_max_fragment_length_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_cid_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
size_t len )
|
||||
@ -755,6 +767,7 @@ static int ssl_parse_cid_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
|
||||
|
||||
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_encrypt_then_mac_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
size_t len )
|
||||
@ -780,6 +793,7 @@ static int ssl_parse_encrypt_then_mac_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
|
||||
|
||||
#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_extended_ms_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
size_t len )
|
||||
@ -805,6 +819,7 @@ static int ssl_parse_extended_ms_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_session_ticket_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
size_t len )
|
||||
@ -831,6 +846,7 @@ static int ssl_parse_session_ticket_ext( mbedtls_ssl_context *ssl,
|
||||
|
||||
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_supported_point_formats_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
size_t len )
|
||||
@ -879,6 +895,7 @@ static int ssl_parse_supported_point_formats_ext( mbedtls_ssl_context *ssl,
|
||||
MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_ecjpake_kkpp( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
size_t len )
|
||||
@ -913,6 +930,7 @@ static int ssl_parse_ecjpake_kkpp( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_SSL_ALPN)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_alpn_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf, size_t len )
|
||||
{
|
||||
@ -983,6 +1001,7 @@ static int ssl_parse_alpn_ext( mbedtls_ssl_context *ssl,
|
||||
#endif /* MBEDTLS_SSL_ALPN */
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_SRTP)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_use_srtp_ext( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *buf,
|
||||
size_t len )
|
||||
@ -1103,6 +1122,7 @@ static int ssl_parse_use_srtp_ext( mbedtls_ssl_context *ssl,
|
||||
* Parse HelloVerifyRequest. Only called after verifying the HS type.
|
||||
*/
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_hello_verify_request( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
const unsigned char *p = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl );
|
||||
@ -1184,6 +1204,7 @@ static int ssl_parse_hello_verify_request( mbedtls_ssl_context *ssl )
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_server_hello( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret, i;
|
||||
@ -1716,6 +1737,7 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl )
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_server_dh_params( mbedtls_ssl_context *ssl,
|
||||
unsigned char **p,
|
||||
unsigned char *end )
|
||||
@ -1761,6 +1783,7 @@ static int ssl_parse_server_dh_params( mbedtls_ssl_context *ssl,
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_server_ecdh_params( mbedtls_ssl_context *ssl,
|
||||
unsigned char **p,
|
||||
unsigned char *end )
|
||||
@ -1825,6 +1848,7 @@ static int ssl_parse_server_ecdh_params( mbedtls_ssl_context *ssl,
|
||||
return( 0 );
|
||||
}
|
||||
#else
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_check_server_ecdh_params( const mbedtls_ssl_context *ssl )
|
||||
{
|
||||
const mbedtls_ecp_curve_info *curve_info;
|
||||
@ -1853,6 +1877,7 @@ static int ssl_check_server_ecdh_params( const mbedtls_ssl_context *ssl )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_server_ecdh_params( mbedtls_ssl_context *ssl,
|
||||
unsigned char **p,
|
||||
unsigned char *end )
|
||||
@ -1893,6 +1918,7 @@ static int ssl_parse_server_ecdh_params( mbedtls_ssl_context *ssl,
|
||||
MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_server_psk_hint( mbedtls_ssl_context *ssl,
|
||||
unsigned char **p,
|
||||
unsigned char *end )
|
||||
@ -1939,6 +1965,7 @@ static int ssl_parse_server_psk_hint( mbedtls_ssl_context *ssl,
|
||||
/*
|
||||
* Generate a pre-master secret and encrypt it with the server's RSA key
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_encrypted_pms( mbedtls_ssl_context *ssl,
|
||||
size_t offset, size_t *olen,
|
||||
size_t pms_offset )
|
||||
@ -2021,6 +2048,7 @@ static int ssl_write_encrypted_pms( mbedtls_ssl_context *ssl,
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_signature_algorithm( mbedtls_ssl_context *ssl,
|
||||
unsigned char **p,
|
||||
unsigned char *end,
|
||||
@ -2079,6 +2107,7 @@ static int ssl_parse_signature_algorithm( mbedtls_ssl_context *ssl,
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_get_ecdh_params_from_cert( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -2097,6 +2126,8 @@ static int ssl_get_ecdh_params_from_cert( mbedtls_ssl_context *ssl )
|
||||
peer_pk = &ssl->session_negotiate->peer_cert->pk;
|
||||
#endif /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
|
||||
|
||||
/* This is a public key, so it can't be opaque, so can_do() is a good
|
||||
* enough check to ensure pk_ec() is safe to use below. */
|
||||
if( ! mbedtls_pk_can_do( peer_pk, MBEDTLS_PK_ECKEY ) )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "server key not ECDH capable" ) );
|
||||
@ -2166,6 +2197,7 @@ static int ssl_get_ecdh_params_from_cert( mbedtls_ssl_context *ssl )
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) ||
|
||||
MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -2513,6 +2545,7 @@ exit:
|
||||
}
|
||||
|
||||
#if ! defined(MBEDTLS_KEY_EXCHANGE_CERT_REQ_ALLOWED_ENABLED)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
|
||||
@ -2531,6 +2564,7 @@ static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl )
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
#else /* MBEDTLS_KEY_EXCHANGE_CERT_REQ_ALLOWED_ENABLED */
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -2734,6 +2768,7 @@ exit:
|
||||
}
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_CERT_REQ_ALLOWED_ENABLED */
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_server_hello_done( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -2773,6 +2808,7 @@ static int ssl_parse_server_hello_done( mbedtls_ssl_context *ssl )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
@ -3295,6 +3331,7 @@ ecdh_calc_secret:
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_KEY_EXCHANGE_CERT_REQ_ALLOWED_ENABLED)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
|
||||
@ -3320,6 +3357,7 @@ static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl )
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
#else /* !MBEDTLS_KEY_EXCHANGE_CERT_REQ_ALLOWED_ENABLED */
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE;
|
||||
@ -3459,6 +3497,7 @@ sign:
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_CERT_REQ_ALLOWED_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_parse_new_session_ticket( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user