Use MBEDTLS_GET_UINTxx_BE macro
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
b2e8419b50
commit
a3d0f61aec
7 changed files with 43 additions and 67 deletions
|
@ -941,7 +941,7 @@ static int ssl_parse_alpn_ext(mbedtls_ssl_context *ssl,
|
|||
return MBEDTLS_ERR_SSL_DECODE_ERROR;
|
||||
}
|
||||
|
||||
list_len = (buf[0] << 8) | buf[1];
|
||||
list_len = MBEDTLS_GET_UINT16_BE(buf, 0);
|
||||
if (list_len != len - 2) {
|
||||
mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
|
||||
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR);
|
||||
|
@ -1304,8 +1304,7 @@ static int ssl_parse_server_hello(mbedtls_ssl_context *ssl)
|
|||
}
|
||||
|
||||
if (ssl->in_hslen > mbedtls_ssl_hs_hdr_len(ssl) + 39 + n) {
|
||||
ext_len = ((buf[38 + n] << 8)
|
||||
| (buf[39 + n]));
|
||||
ext_len = MBEDTLS_GET_UINT16_BE(buf, 38 + n);
|
||||
|
||||
if ((ext_len > 0 && ext_len < 4) ||
|
||||
ssl->in_hslen != mbedtls_ssl_hs_hdr_len(ssl) + 40 + n + ext_len) {
|
||||
|
@ -1326,7 +1325,7 @@ static int ssl_parse_server_hello(mbedtls_ssl_context *ssl)
|
|||
}
|
||||
|
||||
/* ciphersuite (used later) */
|
||||
i = (buf[35 + n] << 8) | buf[36 + n];
|
||||
i = (int) MBEDTLS_GET_UINT16_BE(buf, n + 35);
|
||||
|
||||
/*
|
||||
* Read and check compression
|
||||
|
@ -1447,10 +1446,8 @@ static int ssl_parse_server_hello(mbedtls_ssl_context *ssl)
|
|||
ext_len));
|
||||
|
||||
while (ext_len) {
|
||||
unsigned int ext_id = ((ext[0] << 8)
|
||||
| (ext[1]));
|
||||
unsigned int ext_size = ((ext[2] << 8)
|
||||
| (ext[3]));
|
||||
unsigned int ext_id = MBEDTLS_GET_UINT16_BE(ext, 0);
|
||||
unsigned int ext_size = MBEDTLS_GET_UINT16_BE(ext, 2);
|
||||
|
||||
if (ext_size + 4 > ext_len) {
|
||||
MBEDTLS_SSL_DEBUG_MSG(1, ("bad server hello message"));
|
||||
|
@ -1741,9 +1738,8 @@ static int ssl_parse_server_ecdh_params(mbedtls_ssl_context *ssl,
|
|||
}
|
||||
|
||||
/* Next two bytes are the namedcurve value */
|
||||
tls_id = *(*p)++;
|
||||
tls_id <<= 8;
|
||||
tls_id |= *(*p)++;
|
||||
tls_id = MBEDTLS_GET_UINT16_BE(*p, 0);
|
||||
*p += 2;
|
||||
|
||||
/* Check it's a curve we offered */
|
||||
if (mbedtls_ssl_check_curve_tls_id(ssl, tls_id) != 0) {
|
||||
|
@ -1883,7 +1879,7 @@ static int ssl_parse_server_psk_hint(mbedtls_ssl_context *ssl,
|
|||
("bad server key exchange message (psk_identity_hint length)"));
|
||||
return MBEDTLS_ERR_SSL_DECODE_ERROR;
|
||||
}
|
||||
len = (*p)[0] << 8 | (*p)[1];
|
||||
len = MBEDTLS_GET_UINT16_BE(*p, 0);
|
||||
*p += 2;
|
||||
|
||||
if (end - (*p) < len) {
|
||||
|
@ -2357,7 +2353,7 @@ start_processing:
|
|||
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR);
|
||||
return MBEDTLS_ERR_SSL_DECODE_ERROR;
|
||||
}
|
||||
sig_len = (p[0] << 8) | p[1];
|
||||
sig_len = MBEDTLS_GET_UINT16_BE(p, 0);
|
||||
p += 2;
|
||||
|
||||
if (p != end - sig_len) {
|
||||
|
@ -2585,8 +2581,7 @@ static int ssl_parse_certificate_request(mbedtls_ssl_context *ssl)
|
|||
}
|
||||
|
||||
/* supported_signature_algorithms */
|
||||
sig_alg_len = ((buf[mbedtls_ssl_hs_hdr_len(ssl) + 1 + n] << 8)
|
||||
| (buf[mbedtls_ssl_hs_hdr_len(ssl) + 2 + n]));
|
||||
sig_alg_len = MBEDTLS_GET_UINT16_BE(buf, mbedtls_ssl_hs_hdr_len(ssl) + 1 + n);
|
||||
|
||||
/*
|
||||
* The furthest access in buf is in the loop few lines below:
|
||||
|
@ -2621,8 +2616,7 @@ static int ssl_parse_certificate_request(mbedtls_ssl_context *ssl)
|
|||
n += 2 + sig_alg_len;
|
||||
|
||||
/* certificate_authorities */
|
||||
dn_len = ((buf[mbedtls_ssl_hs_hdr_len(ssl) + 1 + n] << 8)
|
||||
| (buf[mbedtls_ssl_hs_hdr_len(ssl) + 2 + n]));
|
||||
dn_len = MBEDTLS_GET_UINT16_BE(buf, mbedtls_ssl_hs_hdr_len(ssl) + 1 + n);
|
||||
|
||||
n += dn_len;
|
||||
if (ssl->in_hslen != mbedtls_ssl_hs_hdr_len(ssl) + 3 + n) {
|
||||
|
@ -3421,10 +3415,9 @@ static int ssl_parse_new_session_ticket(mbedtls_ssl_context *ssl)
|
|||
|
||||
msg = ssl->in_msg + mbedtls_ssl_hs_hdr_len(ssl);
|
||||
|
||||
lifetime = (((uint32_t) msg[0]) << 24) | (msg[1] << 16) |
|
||||
(msg[2] << 8) | (msg[3]);
|
||||
lifetime = MBEDTLS_GET_UINT32_BE(msg, 0);
|
||||
|
||||
ticket_len = (msg[4] << 8) | (msg[5]);
|
||||
ticket_len = MBEDTLS_GET_UINT16_BE(msg, 4);
|
||||
|
||||
if (ticket_len + 6 + mbedtls_ssl_hs_hdr_len(ssl) != ssl->in_hslen) {
|
||||
MBEDTLS_SSL_DEBUG_MSG(1, ("bad new session ticket message"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue