Introduce zlen size variable in ECHDE-PSK part of ssl_parse_client_key_exchange()
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
diff --git a/library/ssl_tls12_server.c b/library/ssl_tls12_server.c
index 7bf3569..fda5db5 100644
--- a/library/ssl_tls12_server.c
+++ b/library/ssl_tls12_server.c
@@ -4083,6 +4083,8 @@
unsigned char *psm = ssl->handshake->premaster;
const unsigned char* const psm_end =
psm + sizeof( ssl->handshake->premaster );
+ /* uint16 to store length (in octets) of the ECDH computation */
+ const size_t zlen_size = 2;
size_t zlen = 0;
/* Compute ECDH shared secret. */
@@ -4090,8 +4092,8 @@
handshake->ecdh_psa_privkey,
handshake->ecdh_psa_peerkey,
handshake->ecdh_psa_peerkey_len,
- psm + 2,
- psm_end - ( psm + 2 ),
+ psm + zlen_size,
+ psm_end - ( psm + zlen_size ),
&zlen );
destruction_status = psa_destroy_key( handshake->ecdh_psa_privkey );
@@ -4104,7 +4106,7 @@
/* Write the ECDH computation length before the ECDH computation */
MBEDTLS_PUT_UINT16_BE( zlen, psm, 0 );
- psm += 2 + zlen;
+ psm += zlen_size + zlen;
/* opaque psk<0..2^16-1>; */
if( psm_end - psm < 2 )