Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request ARMmbed#3176 from aggarg/development #11

Merged
merged 100 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
b51130d
Parse HelloVerifyRequest: avoid buffer overread on the cookie
gilles-peskine-arm Sep 27, 2019
b64bf06
Parse HelloVerifyRequest: avoid buffer overread at the start
gilles-peskine-arm Sep 27, 2019
1c66813
Parse HelloVerifyRequest buffer overread: add changelog entry
gilles-peskine-arm Sep 27, 2019
03954f2
Make negative function_id value impossible in test suites
k-stachowiak Sep 16, 2019
56e99d6
Make sure to use a Python 3 pylint
gilles-peskine-arm Mar 24, 2020
13c95c4
Make check_python_files non-optional in all.sh
gilles-peskine-arm Mar 24, 2020
ce674a9
Clearer code to search for config.h
gilles-peskine-arm Mar 24, 2020
e22a4da
Explicit return value from main
gilles-peskine-arm Mar 24, 2020
49f4679
Pylint: allow if-return-else-return
gilles-peskine-arm Mar 24, 2020
46c54c0
Pylint: disable logging-format-interpolation warning
gilles-peskine-arm Mar 24, 2020
e40a2f7
Improve documentation about PSK configuration
gbryant-arm Mar 25, 2020
d511ac3
Define internal PSK getter
gbryant-arm Mar 25, 2020
c5285d8
Use internal PSK getter
gbryant-arm Mar 25, 2020
82194c8
Fix bracketing style in ssl_tls.c
gbryant-arm Mar 26, 2020
a4aa89b
Fix leakage of projective coordinates in ECC
mpg Mar 25, 2020
61b0fe6
Initialise psk_len in mbedtls_ssl_psk_derive_premaster()
gbryant-arm Mar 27, 2020
8a69ddd
Fix Doxygen comments
gbryant-arm Mar 27, 2020
6e8d5a0
Clarify confusion between file names and suffixes of file names
gilles-peskine-arm Mar 24, 2020
6a45d1e
List each item on a separate line for easier maintenance
gilles-peskine-arm Mar 24, 2020
5308f12
Sort the list for easier maintenance
gilles-peskine-arm Mar 24, 2020
2c61873
Also check Windows files
gilles-peskine-arm Mar 24, 2020
545e13f
Check that Windows files have Windows line endings
gilles-peskine-arm Mar 24, 2020
b5f04e4
Properly initialise psk and psk_len
gbryant-arm Apr 1, 2020
d703a2e
In Windows files, detect CR without LF as well as LF without CR
gilles-peskine-arm Apr 1, 2020
0f3f9c3
Fix a stray CR inside a line
gilles-peskine-arm Apr 1, 2020
2ae678d
Systematically use Windows line endings in Windows files
gilles-peskine-arm Mar 24, 2020
9039dc4
Improve ctags invocation in Makefile
mpg Apr 2, 2020
c9f8956
Allow alternative ctags versions in Makefile
mpg Apr 2, 2020
e1a05a5
unit tests main: Fix potential buffer overflow
ronald-cron-arm Apr 1, 2020
67a8a37
unit test: Indicate missing unmet dependencies
ronald-cron-arm Apr 1, 2020
03d3711
Fix bracket style
gbryant-arm Apr 3, 2020
ea6af48
Merge pull request #675 from mpg/ecc-projective-restricted
yanesca Apr 6, 2020
4500e83
Merge pull request #3156 from mpg/improve-make-tags
gilles-peskine-arm Apr 6, 2020
0c9b195
Return internal error if no PSK is found when deriving the premaster …
gbryant-arm Apr 8, 2020
dca973b
Merge branch 'development-restricted' into mbedtls-2.22.0r0
yanesca Apr 8, 2020
ee85686
Add missing ChangeLog entry
yanesca Apr 8, 2020
876e025
Bump version to Mbed TLS 2.22.0
yanesca Apr 8, 2020
e52fd3f
Fix integer overflow in benchmark program
mpg Apr 9, 2020
90c6e84
Split the maximum fragment length into two - an input and output MFL
Apr 3, 2020
8ea6872
Improve pointer calculations when resizing I/O buffers
Apr 3, 2020
940bc00
Add missing ChangeLog entry
yanesca Apr 9, 2020
a9f6400
Add support for const error description strings
aggarg Apr 9, 2020
215d2e1
Merge remote-tracking branch 'restricted/pr/662' into development-res…
mpg Apr 9, 2020
2848239
Merge branch 'development-restricted' into prepare-rc-2.22.0-updated
mpg Apr 9, 2020
66e21ef
Merge pull request #3163 from AndrzejKurek/variable-buffers-renegotia…
Patater Apr 9, 2020
105c996
Merge pull request #681 from ARMmbed/prepare-rc-2.22.0-updated
yanesca Apr 9, 2020
6d6ee98
Exit with a failure status if some tests failed
gilles-peskine-arm Apr 9, 2020
a4a2aa5
Address review comments
aggarg Apr 9, 2020
ca51b47
Note that we keep going even if some tests fail
gilles-peskine-arm Apr 9, 2020
5757d54
If 'make lcov' failed, exit immediately
gilles-peskine-arm Apr 9, 2020
bfcb6e1
Create a large enough seedfile
gilles-peskine-arm Apr 9, 2020
40be51f
Add a few echo statements to make the logs easier to follow
gilles-peskine-arm Apr 9, 2020
b3d0bab
MBEDTLS_MEMORY_BACKTRACE is no longer included in the full config
gilles-peskine-arm Apr 9, 2020
c877c24
Enable extra features that have tests
gilles-peskine-arm Apr 9, 2020
e62bdef
Merge pull request #3181 from gilles-peskine-arm/basic-build-test-sta…
gilles-peskine-arm Apr 10, 2020
aaee444
Document more methods in Python scripts
gilles-peskine-arm Mar 24, 2020
dd4c1c6
mbedtls_test.py: drop compatibility with Python 2
gilles-peskine-arm Mar 24, 2020
184c096
Pylint: abide by useless-object-inheritance warnings
gilles-peskine-arm Mar 24, 2020
8b02235
Pylint: minor code simplifications
gilles-peskine-arm Mar 24, 2020
7747efc
Pylint: allow using pass even when not strictly necessary
gilles-peskine-arm Mar 24, 2020
1759602
Pylint: silence locally-disabled/enabled messages
gilles-peskine-arm Mar 24, 2020
e0c84ac
Pylint: explicitly note why we're doing an unchecked subprocess.run
gilles-peskine-arm Mar 24, 2020
3d02db2
Add auto-generated code markers
aggarg Apr 12, 2020
ac15f84
Merge remote-tracking branch 'restricted/pr/684' into mbedtls-2.22.0r0
yanesca Apr 14, 2020
9370f90
Initial work on the ssl dump program from base64 code
piotr-now Mar 13, 2020
88ebbbf
Add function for parsing arguments
piotr-now Mar 13, 2020
14d3105
Add reading base64 code from file
piotr-now Mar 16, 2020
6842c9b
Add printing the read base64 code
piotr-now Mar 16, 2020
c7d681c
Add base64 code decoding
piotr-now Mar 17, 2020
6b2baf9
Print mbedtls version and configuration
piotr-now Mar 17, 2020
ab3ecd8
Print more information and add TODOs
piotr-now Mar 18, 2020
4e19200
Add session deserializing (not completed)
piotr-now Mar 18, 2020
5d318cc
Merge pull request #3130 from gbryant-arm/generic-psk
mpg Apr 14, 2020
e5fa8b7
Add certificate printing
piotr-now Mar 20, 2020
f86192f
Add support for Microsoft Visual Studio
piotr-now Mar 26, 2020
bc876d4
Rename program 'ssl_base64_dump' to 'ssl_context_info'
piotr-now Mar 26, 2020
02cc3fb
Add dynamic buffer allocation and size checking
piotr-now Mar 30, 2020
97dcb1c
Add required configuration to the ssl_context_info
piotr-now Apr 9, 2020
a18c4f3
Merge pull request #686 from ARMmbed/merge-2.22.0-release-to-development
yanesca Apr 14, 2020
1605074
Guard from undefined behaviour in case of an INT_MAX max_pathlen
Apr 14, 2020
9978e6e
Add tests for the ssl_context_info program
piotr-now Apr 7, 2020
ed9e477
Merge pull request #3127 from piotr-now/ssl_base64_dump
Patater Apr 16, 2020
31f4cd9
Merge pull request #3192 from AndrzejKurek/max_pathlen_overflow
Patater Apr 16, 2020
5f69cbe
Merge pull request #3155 from ronald-cron-arm/unmet-dependencies-buff…
gilles-peskine-arm Apr 17, 2020
5edd388
Get rid of a magic value in benchmark.c
mpg Apr 9, 2020
10a5b53
Sort lists in Makefiles and have one item per line
mpg Apr 3, 2020
6f83025
Sort lists in CMakeLists.txt files
mpg Apr 3, 2020
6ff1189
Sort lists in .gitignore files
mpg Apr 3, 2020
136bebf
Add missing newline character
piotr-now Apr 17, 2020
3de298f
Saving the serialized context to a file
piotr-now Apr 16, 2020
5c34ee1
Merge pull request #3118 from gilles-peskine-arm/pylint-up-to-2.4-dev…
gilles-peskine-arm Apr 20, 2020
bb6b163
Merge pull request #3162 from mpg/sort-lists
gilles-peskine-arm Apr 20, 2020
23352a3
Merge pull request #3177 from mpg/fix-overflow-benchmark-dev
gilles-peskine-arm Apr 20, 2020
5a2710e
Merge pull request #3120 from gilles-peskine-arm/check-windows-files
gilles-peskine-arm Apr 20, 2020
b72df54
Merge pull request #2840 from k-stachowiak/check-bounds-of-test-intex…
gilles-peskine-arm Apr 20, 2020
3a7ca1d
Merge pull request #3194 from piotr-now/serialized_to_file
Patater Apr 20, 2020
3669208
Re-run generate_visualc_files.pl
gilles-peskine-arm Apr 20, 2020
6ea4fc7
Address review comments
aggarg Apr 20, 2020
e50c6ed
Merge pull request #3210 from gilles-peskine-arm/ssl_context_info-fix…
gilles-peskine-arm Apr 21, 2020
dc9c47d
Merge pull request #3176 from aggarg/development
gilles-peskine-arm Apr 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,27 @@ max-attributes=15
max-module-lines=2000

[MESSAGES CONTROL]
disable=
# * locally-disabled, locally-enabled: If we disable or enable a message
# locally, it's by design. There's no need to clutter the Pylint output
# with this information.
# * logging-format-interpolation: Pylint warns about things like
# ``log.info('...'.format(...))``. It insists on ``log.info('...', ...)``.
# This is of minor utility (mainly a performance gain when there are
# many messages that use formatting and are below the log level).
# Some versions of Pylint (including 1.8, which is the version on
# Ubuntu 18.04) only recognize old-style format strings using '%',
# and complain about something like ``log.info('{}', foo)`` with
# logging-too-many-args (Pylint supports new-style formatting if
# declared globally with logging_format_style under [LOGGING] but
# this requires Pylint >=2.2).
# * no-else-return: Allow the perfectly reasonable idiom
# if condition1:
# return value1
# else:
# return value2
# * unnecessary-pass: If we take the trouble of adding a line with "pass",
# it's because we think the code is clearer that way.
disable=locally-disabled,locally-enabled,logging-format-interpolation,no-else-return,unnecessary-pass

[REPORTS]
# Don't diplay statistics. Just the facts.
Expand Down
25 changes: 24 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
mbed TLS ChangeLog (Sorted per branch, date)

= mbed TLS x.x.x branch released xxxx-xx-xx
= mbed TLS 2.22.0 branch released 2020-04-14

New deprecations
* Deprecate MBEDTLS_SSL_HW_RECORD_ACCEL that enables function hooks in the
SSL module for hardware acceleration of individual records.
* Deprecate mbedtls_ssl_get_max_frag_len() in favour of
mbedtls_ssl_get_output_max_frag_len() and
mbedtls_ssl_get_input_max_frag_len() to be more precise about which max
fragment length is desired.

Security
* Fix issue in DTLS handling of new associations with the same parameters
Expand All @@ -13,16 +17,35 @@ Security
legitimate clients, resulting in a Denial of Service. This could only
happen when MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE was enabled in config.h
(which it is by default).
* Fix side channel in ECC code that allowed an adversary with access to
precise enough timing and memory access information (typically an
untrusted operating system attacking a secure enclave) to fully recover
an ECDSA private key. Found and reported by Alejandro Cabrera Aldaya,
Billy Brumley and Cesar Pereida Garcia. CVE-2020-10932
* Fix a potentially remotely exploitable buffer overread in a
DTLS client when parsing the Hello Verify Request message.

Features
* The new build option MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH automatically
resizes the I/O buffers before and after handshakes, reducing the memory
consumption during application data transfer.

Bugfix
* Fix compilation failure when both MBEDTLS_SSL_PROTO_DTLS and
MBEDTLS_SSL_HW_RECORD_ACCEL are enabled.
* Remove a spurious check in ssl_parse_client_psk_identity that triggered
a warning with some compilers. Fix contributed by irwir in #2856.
* Fix a function name in a debug message. Contributed by Ercan Ozturk in
#3013.

Changes
* Mbed Crypto is no longer a Git submodule. The crypto part of the library
is back directly in the present repository.
* Split mbedtls_ssl_get_max_frag_len() into
mbedtls_ssl_get_output_max_frag_len() and
mbedtls_ssl_get_input_max_frag_len() to ensure that a sufficient input
buffer is allocated by the server (if MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
is defined), regardless of what MFL was configured for it.

= mbed TLS 2.21.0 branch released 2020-02-20

Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ endif

## Editor navigation files
C_SOURCE_FILES = $(wildcard include/*/*.h library/*.[hc] programs/*/*.[hc] tests/suites/*.function)
# Exuberant-ctags invocation. Other ctags implementations may require different options.
CTAGS = ctags --langmap=c:+.h.function -o
tags: $(C_SOURCE_FILES)
ctags -o $@ $(C_SOURCE_FILES)
$(CTAGS) $@ $(C_SOURCE_FILES)
TAGS: $(C_SOURCE_FILES)
etags -o $@ $(C_SOURCE_FILES)
GPATH GRTAGS GSYMS GTAGS: $(C_SOURCE_FILES)
Expand Down
2 changes: 1 addition & 1 deletion doxygen/input/doc_mainpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

/**
* @mainpage mbed TLS v2.21.0 source code documentation
* @mainpage mbed TLS v2.22.0 source code documentation
*
* This documentation describes the internal structure of mbed TLS. It was
* automatically generated from specially formatted comment blocks in
Expand Down
2 changes: 1 addition & 1 deletion doxygen/mbedtls.doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DOXYFILE_ENCODING = UTF-8
# identify the project. Note that if you do not use Doxywizard you need
# to put quotes around the project name if it contains spaces.

PROJECT_NAME = "mbed TLS v2.21.0"
PROJECT_NAME = "mbed TLS v2.22.0"

# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
Expand Down
30 changes: 30 additions & 0 deletions include/mbedtls/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,36 @@ extern "C" {
*/
void mbedtls_strerror( int errnum, char *buffer, size_t buflen );

/**
* \brief Translate the high-level part of an Mbed TLS error code into a string
* representation.
*
* This function returns a const pointer to an un-modifiable string. The caller
* must not try to modify the string. It is intended to be used mostly for
* logging purposes.
*
* \param error_code error code
*
* \return The string representation of the error code, or \c NULL if the error
* code is unknown.
*/
const char * mbedtls_high_level_strerr( int error_code );

/**
* \brief Translate the low-level part of an Mbed TLS error code into a string
* representation.
*
* This function returns a const pointer to an un-modifiable string. The caller
* must not try to modify the string. It is intended to be used mostly for
* logging purposes.
*
* \param error_code error code
*
* \return The string representation of the error code, or \c NULL if the error
* code is unknown.
*/
const char * mbedtls_low_level_strerr( int error_code );

#ifdef __cplusplus
}
#endif
Expand Down
84 changes: 73 additions & 11 deletions include/mbedtls/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2682,6 +2682,9 @@ int mbedtls_ssl_conf_own_cert( mbedtls_ssl_config *conf,
* \note This is mainly useful for clients. Servers will usually
* want to use \c mbedtls_ssl_conf_psk_cb() instead.
*
* \note A PSK set by \c mbedtls_ssl_set_hs_psk() in the PSK callback
* takes precedence over a PSK configured by this function.
*
* \warning Currently, clients can only register a single pre-shared key.
* Calling this function or mbedtls_ssl_conf_psk_opaque() more
* than once will overwrite values configured in previous calls.
Expand Down Expand Up @@ -2715,6 +2718,10 @@ int mbedtls_ssl_conf_psk( mbedtls_ssl_config *conf,
* \note This is mainly useful for clients. Servers will usually
* want to use \c mbedtls_ssl_conf_psk_cb() instead.
*
* \note An opaque PSK set by \c mbedtls_ssl_set_hs_psk_opaque() in
* the PSK callback takes precedence over an opaque PSK
* configured by this function.
*
* \warning Currently, clients can only register a single pre-shared key.
* Calling this function or mbedtls_ssl_conf_psk() more than
* once will overwrite values configured in previous calls.
Expand Down Expand Up @@ -2752,6 +2759,9 @@ int mbedtls_ssl_conf_psk_opaque( mbedtls_ssl_config *conf,
* \note This should only be called inside the PSK callback,
* i.e. the function passed to \c mbedtls_ssl_conf_psk_cb().
*
* \note A PSK set by this function takes precedence over a PSK
* configured by \c mbedtls_ssl_conf_psk().
*
* \param ssl The SSL context to configure a PSK for.
* \param psk The pointer to the pre-shared key.
* \param psk_len The length of the pre-shared key in bytes.
Expand All @@ -2769,6 +2779,9 @@ int mbedtls_ssl_set_hs_psk( mbedtls_ssl_context *ssl,
* \note This should only be called inside the PSK callback,
* i.e. the function passed to \c mbedtls_ssl_conf_psk_cb().
*
* \note An opaque PSK set by this function takes precedence over an
* opaque PSK configured by \c mbedtls_ssl_conf_psk_opaque().
*
* \param ssl The SSL context to configure a PSK for.
* \param psk The identifier of the key slot holding the PSK.
* For the duration of the current handshake, the key slot
Expand Down Expand Up @@ -2807,9 +2820,14 @@ int mbedtls_ssl_set_hs_psk_opaque( mbedtls_ssl_context *ssl,
* on the SSL context to set the correct PSK and return \c 0.
* Any other return value will result in a denied PSK identity.
*
* \note If you set a PSK callback using this function, then you
* don't need to set a PSK key and identity using
* \c mbedtls_ssl_conf_psk().
* \note A dynamic PSK (i.e. set by the PSK callback) takes
* precedence over a static PSK (i.e. set by
* \c mbedtls_ssl_conf_psk() or
* \c mbedtls_ssl_conf_psk_opaque()).
* This means that if you set a PSK callback using this
* function, you don't need to set a PSK using
* \c mbedtls_ssl_conf_psk() or
* \c mbedtls_ssl_conf_psk_opaque()).
*
* \param conf The SSL configuration to register the callback with.
* \param f_psk The callback for selecting and setting the PSK based
Expand Down Expand Up @@ -3523,18 +3541,61 @@ int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl );

#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
/**
* \brief Return the maximum fragment length (payload, in bytes).
* This is the value negotiated with peer if any,
* or the locally configured value.
* \brief Return the maximum fragment length (payload, in bytes) for
* the output buffer. For the client, this is the configured
* value. For the server, it is the minimum of two - the
* configured value and the negotiated one.
*
* \sa mbedtls_ssl_conf_max_frag_len()
* \sa mbedtls_ssl_get_max_record_payload()
*
* \param ssl SSL context
*
* \return Current maximum fragment length.
* \return Current maximum fragment length for the output buffer.
*/
size_t mbedtls_ssl_get_max_frag_len( const mbedtls_ssl_context *ssl );
size_t mbedtls_ssl_get_output_max_frag_len( const mbedtls_ssl_context *ssl );

/**
* \brief Return the maximum fragment length (payload, in bytes) for
* the input buffer. This is the negotiated maximum fragment
* length, or, if there is none, MBEDTLS_SSL_MAX_CONTENT_LEN.
* If it is not defined either, the value is 2^14. This function
* works as its predecessor, \c mbedtls_ssl_get_max_frag_len().
*
* \sa mbedtls_ssl_conf_max_frag_len()
* \sa mbedtls_ssl_get_max_record_payload()
*
* \param ssl SSL context
*
* \return Current maximum fragment length for the output buffer.
*/
size_t mbedtls_ssl_get_input_max_frag_len( const mbedtls_ssl_context *ssl );

#if !defined(MBEDTLS_DEPRECATED_REMOVED)

#if defined(MBEDTLS_DEPRECATED_WARNING)
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
#else
#define MBEDTLS_DEPRECATED
#endif

/**
* \brief This function is a deprecated approach to getting the max
* fragment length. Its an alias for
* \c mbedtls_ssl_get_output_max_frag_len(), as the behaviour
* is the same. See \c mbedtls_ssl_get_output_max_frag_len() for
* more detail.
*
* \sa mbedtls_ssl_get_input_max_frag_len()
* \sa mbedtls_ssl_get_output_max_frag_len()
*
* \param ssl SSL context
*
* \return Current maximum fragment length for the output buffer.
*/
MBEDTLS_DEPRECATED size_t mbedtls_ssl_get_max_frag_len(
const mbedtls_ssl_context *ssl );
#endif /* MBEDTLS_DEPRECATED_REMOVED */
#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */

/**
Expand All @@ -3555,7 +3616,8 @@ size_t mbedtls_ssl_get_max_frag_len( const mbedtls_ssl_context *ssl );
* when record compression is enabled.
*
* \sa mbedtls_ssl_set_mtu()
* \sa mbedtls_ssl_get_max_frag_len()
* \sa mbedtls_ssl_get_output_max_frag_len()
* \sa mbedtls_ssl_get_input_max_frag_len()
* \sa mbedtls_ssl_get_record_expansion()
*
* \param ssl SSL context
Expand Down Expand Up @@ -3863,8 +3925,8 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len )
* or negotiated with the peer), then:
* - with TLS, less bytes than requested are written.
* - with DTLS, MBEDTLS_ERR_SSL_BAD_INPUT_DATA is returned.
* \c mbedtls_ssl_get_max_frag_len() may be used to query the
* active maximum fragment length.
* \c mbedtls_ssl_get_output_max_frag_len() may be used to
* query the active maximum fragment length.
*
* \note Attempting to write 0 bytes will result in an empty TLS
* application record being sent.
Expand Down
63 changes: 58 additions & 5 deletions include/mbedtls/ssl_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,23 +260,23 @@
static inline uint32_t mbedtls_ssl_get_output_buflen( const mbedtls_ssl_context *ctx )
{
#if defined (MBEDTLS_SSL_DTLS_CONNECTION_ID)
return (uint32_t) mbedtls_ssl_get_max_frag_len( ctx )
return (uint32_t) mbedtls_ssl_get_output_max_frag_len( ctx )
+ MBEDTLS_SSL_HEADER_LEN + MBEDTLS_SSL_PAYLOAD_OVERHEAD
+ MBEDTLS_SSL_CID_OUT_LEN_MAX;
#else
return (uint32_t) mbedtls_ssl_get_max_frag_len( ctx )
return (uint32_t) mbedtls_ssl_get_output_max_frag_len( ctx )
+ MBEDTLS_SSL_HEADER_LEN + MBEDTLS_SSL_PAYLOAD_OVERHEAD;
#endif
}

static inline uint32_t mbedtls_ssl_get_input_buflen( const mbedtls_ssl_context *ctx )
{
#if defined (MBEDTLS_SSL_DTLS_CONNECTION_ID)
return (uint32_t) mbedtls_ssl_get_max_frag_len( ctx )
return (uint32_t) mbedtls_ssl_get_input_max_frag_len( ctx )
+ MBEDTLS_SSL_HEADER_LEN + MBEDTLS_SSL_PAYLOAD_OVERHEAD
+ MBEDTLS_SSL_CID_IN_LEN_MAX;
#else
return (uint32_t) mbedtls_ssl_get_max_frag_len( ctx )
return (uint32_t) mbedtls_ssl_get_input_max_frag_len( ctx )
+ MBEDTLS_SSL_HEADER_LEN + MBEDTLS_SSL_PAYLOAD_OVERHEAD;
#endif
}
Expand Down Expand Up @@ -921,7 +921,60 @@ void mbedtls_ssl_optimize_checksum( mbedtls_ssl_context *ssl,

#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exchange_type_t key_ex );
#endif

/**
* Get the first defined PSK by order of precedence:
* 1. handshake PSK set by \c mbedtls_ssl_set_hs_psk() in the PSK callback
* 2. static PSK configured by \c mbedtls_ssl_conf_psk()
* Return a code and update the pair (PSK, PSK length) passed to this function
*/
static inline int mbedtls_ssl_get_psk( const mbedtls_ssl_context *ssl,
const unsigned char **psk, size_t *psk_len )
{
if( ssl->handshake->psk != NULL && ssl->handshake->psk_len > 0 )
{
*psk = ssl->handshake->psk;
*psk_len = ssl->handshake->psk_len;
}

else if( ssl->conf->psk != NULL && ssl->conf->psk_len > 0 )
{
*psk = ssl->conf->psk;
*psk_len = ssl->conf->psk_len;
}

else
{
*psk = NULL;
*psk_len = 0;
return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED );
}

return( 0 );
}

#if defined(MBEDTLS_USE_PSA_CRYPTO)
/**
* Get the first defined opaque PSK by order of precedence:
* 1. handshake PSK set by \c mbedtls_ssl_set_hs_psk_opaque() in the PSK
* callback
* 2. static PSK configured by \c mbedtls_ssl_conf_psk_opaque()
* Return an opaque PSK
*/
static inline psa_key_handle_t mbedtls_ssl_get_opaque_psk(
const mbedtls_ssl_context *ssl )
{
if( ssl->handshake->psk_opaque != 0 )
return( ssl->handshake->psk_opaque );

if( ssl->conf->psk_opaque != 0 )
return( ssl->conf->psk_opaque );

return( 0 );
}
#endif /* MBEDTLS_USE_PSA_CRYPTO */

#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */

#if defined(MBEDTLS_PK_C)
unsigned char mbedtls_ssl_sig_from_pk( mbedtls_pk_context *pk );
Expand Down
Loading