tls12: check buffer size before memcpy-ing data into it
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
parent
c9ae862225
commit
46520ea52d
1 changed files with 4 additions and 3 deletions
|
@ -1774,9 +1774,10 @@ static int ssl_parse_server_ecdh_params(mbedtls_ssl_context *ssl,
|
|||
return MBEDTLS_ERR_SSL_DECODE_ERROR;
|
||||
}
|
||||
|
||||
/* xxdh_psa_peerkey is sized after maximum supported FFDH public key.
|
||||
* PSA_VENDOR_FFDH_MAX_KEY_BITS is always larger than EC public key, so
|
||||
* we can skip the buffer size check before the memcpy-ing data into it. */
|
||||
if (ecpoint_len > PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS)) {
|
||||
return MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE;
|
||||
}
|
||||
|
||||
memcpy(handshake->xxdh_psa_peerkey, *p, ecpoint_len);
|
||||
handshake->xxdh_psa_peerkey_len = ecpoint_len;
|
||||
*p += ecpoint_len;
|
||||
|
|
Loading…
Reference in a new issue