mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-07-30 16:26:33 +08:00
Added fix for Integer overflow using a large ECDHE Identity
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
This commit is contained in:
parent
5ca2218a28
commit
baf449db7e
@ -2470,11 +2470,16 @@ static int ssl_write_client_key_exchange(mbedtls_ssl_context *ssl)
|
||||
|
||||
/* uint16 to store content length */
|
||||
const size_t content_len_size = 2;
|
||||
const size_t ecpoint_len_size = 1;
|
||||
const size_t ecpoint_max_len =
|
||||
PSA_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(handshake->xxdh_psa_type,
|
||||
handshake->xxdh_psa_bits);
|
||||
|
||||
header_len = 4;
|
||||
|
||||
if (header_len + content_len_size + ssl->conf->psk_identity_len
|
||||
> MBEDTLS_SSL_OUT_CONTENT_LEN) {
|
||||
if (ecpoint_max_len > MBEDTLS_SSL_OUT_CONTENT_LEN - ecpoint_len_size ||
|
||||
header_len + content_len_size + ssl->conf->psk_identity_len
|
||||
> MBEDTLS_SSL_OUT_CONTENT_LEN - ecpoint_len_size - ecpoint_max_len) {
|
||||
MBEDTLS_SSL_DEBUG_MSG(1,
|
||||
("psk identity too long or SSL buffer too short"));
|
||||
return MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user