ECDH: not restartable unless explicitly enabled
This is mainly for the benefit of SSL modules, which only supports restart in
a limited number of cases. In the other cases (ECDHE_PSK) it would currently
return ERR_ECP_IN_PROGRESS and the user would thus call ssl_handshake() again,
but the SSL code wouldn't handle state properly and things would go wrong in
possibly unexpected ways. This is undesirable, so it should be possible for
the SSL module to choose if ECDHE should behave the old or the new way.
Not that it also brings ECDHE more in line with the other modules which
already have that choice available (by passing a NULL or valid restart
context).
diff --git a/library/ssl_cli.c b/library/ssl_cli.c
index faaedb7..cbd4647 100644
--- a/library/ssl_cli.c
+++ b/library/ssl_cli.c
@@ -2902,6 +2902,9 @@
i = 4;
#if defined(MBEDTLS_SSL__ECP_RESTARTABLE)
+ if( ssl->handshake->ec_restart_enabled)
+ mbedtls_ecdh_enable_restart( &ssl->handshake->ecdh_ctx );
+
if( ssl->handshake->ecrs_state == ssl_ecrs_ecdh_public_done )
goto ecdh_calc_secret;
#endif