Skip to content

Commit 71387e3

Browse files
committed
Mbed TLS: Fix ECC hardware double initialization
We initialized the ECC hardware before calling mbedtls_ecp_mul_shortcuts(). This in turn calls mbedtls_ecp_mul_restartable(), which initializes and frees the hardware too. This issue has been introduced by recent changes and caused some accelerators to hang. We move the initialization after the mbedtle_ecp_mul_shortcuts() calls to avoid double initialization.
1 parent 211c662 commit 71387e3

File tree

1 file changed

+6
-5
lines changed
  • features/mbedtls/src

1 file changed

+6
-5
lines changed

features/mbedtls/src/ecp.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,11 +2393,6 @@ int mbedtls_ecp_muladd_restartable(
23932393

23942394
mbedtls_ecp_point_init( &mP );
23952395

2396-
#if defined(MBEDTLS_ECP_INTERNAL_ALT)
2397-
if( ( is_grp_capable = mbedtls_internal_ecp_grp_capable( grp ) ) )
2398-
MBEDTLS_MPI_CHK( mbedtls_internal_ecp_init( grp ) );
2399-
#endif /* MBEDTLS_ECP_INTERNAL_ALT */
2400-
24012396
ECP_RS_ENTER( ma );
24022397

24032398
#if defined(MBEDTLS_ECP_RESTARTABLE)
@@ -2425,6 +2420,12 @@ int mbedtls_ecp_muladd_restartable(
24252420
mul2:
24262421
#endif
24272422
MBEDTLS_MPI_CHK( mbedtls_ecp_mul_shortcuts( grp, pR, n, Q, rs_ctx ) );
2423+
2424+
#if defined(MBEDTLS_ECP_INTERNAL_ALT)
2425+
if( ( is_grp_capable = mbedtls_internal_ecp_grp_capable( grp ) ) )
2426+
MBEDTLS_MPI_CHK( mbedtls_internal_ecp_init( grp ) );
2427+
#endif /* MBEDTLS_ECP_INTERNAL_ALT */
2428+
24282429
#if defined(MBEDTLS_ECP_RESTARTABLE)
24292430
if( rs_ctx != NULL && rs_ctx->ma != NULL )
24302431
rs_ctx->ma->state = ecp_rsma_add;

0 commit comments

Comments
 (0)