Hi Sirjee,
Does this fail systematically or randomly? Can you reproduce this with a
very small program that only opens a TLS connection and nothing else,
like programs/ssl/ssl_client1?
At a guess, but this is only a guess, maybe this is the part of your
program which uses the largest amount of stack, and there's a stack
overflow that causes some variable to be overwritten. Please try
increasing the stack size.
--
Gilles Peskine
Mbed TLS developer
P.S. The config.h attachment didn't come through, but a graphical
signature did. Please check your email settings when posting to the list.
On 04/05/2020 10:50, Sirjee Rooplall via mbed-tls wrote:
>
>
> Hi Support,
>
> I am using MBEDTLS and most of it works, except I have hit a snag
> where I am trying to communicate to an https server, and it fails in
> the ssl->handshake-step (ssl_write_client_key_exchange).
>
> My stack trace shows that it gets to the function ecp_double_jac and
> never exits. It is looping at
> MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &T, &P->X, &S ) );
> MOD_ADD( T );.
> Stack trace:
> test.elf! mbedtls_mpi_sub_abs (mbedtls_mpi * X, const mbedtls_mpi * A,
> const mbedtls_mpi * B) Line: 1287
> test.elf! ecp_double_jac (const mbedtls_ecp_group * grp,
> mbedtls_ecp_point * R, const mbedtls_ecp_point * P) Line: 1310
> test.elf! ecp_precompute_comb (const mbedtls_ecp_group * grp,
> mbedtls_ecp_point * T, const mbedtls_ecp_point * P, unsigned char w,
> size_t d, mbedtls_ecp_restart_ctx * rs_ctx) Line: 1702
> test.elf! ecp_mul_comb (mbedtls_ecp_group * grp, mbedtls_ecp_point *
> R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, int (*)(void *,
> unsigned char *, size_t) f_rng, void * p_rng, mbedtls_ecp_restart_ctx
> * rs_ctx) Line: 2095
> test.elf! mbedtls_ecp_mul_restartable (mbedtls_ecp_group * grp,
> mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point
> * P, int (*)(void *, unsigned char *, size_t) f_rng, void * p_rng,
> mbedtls_ecp_restart_ctx * rs_ctx) Line: 2396
> test.elf! ecdh_gen_public_restartable (mbedtls_ecp_group * grp,
> mbedtls_mpi * d, mbedtls_ecp_point * Q, int (*)(void *, unsigned char
> *, size_t) f_rng, void * p_rng, mbedtls_ecp_restart_ctx * rs_ctx)
> Line: 84
> test.elf! mbedtls_ecdh_gen_public (mbedtls_ecp_group * grp,
> mbedtls_mpi * d, mbedtls_ecp_point * Q, int (*)(void *, unsigned char
> *, size_t) f_rng, void * p_rng) Line: 102
> test.elf! ecdh_make_public_internal (mbedtls_ecdh_context_mbed *
> ctx, size_t * olen, int point_format, unsigned char * buf, size_t
> blen, int (*)(void *, unsigned char *, size_t) f_rng, void * p_rng,
> int restart_enabled) Line: 514
> test.elf! mbedtls_ecdh_make_public (mbedtls_ecdh_context * ctx,
> size_t * olen, unsigned char * buf, size_t blen, int (*)(void *,
> unsigned char *, size_t) f_rng, void * p_rng) Line: 542
> test.elf! ssl_write_client_key_exchange (mbedtls_ssl_context * ssl)
> Line: 3362
> test.elf! mbedtls_ssl_handshake_client_step (mbedtls_ssl_context *
> ssl) Line: 4015
> test.elf! mbedtls_ssl_handshake_step (mbedtls_ssl_context * ssl)
> Line: 9564
> test.elf! mbedtls_ssl_handshake (mbedtls_ssl_context * ssl) Line: 9588
> test.elf! https_do_tls_handshake (struct httpsConfigStr * client)
> Line: 419
> test.elf! HttpsStateMachine Line: 366
> test.elf! HttpsTask (void * param) Line: 110
> test.elf! ?? Line: 110
>
> MBEDTLS VERSION: mbed TLS 2.18.0
> PLATFORM: embedded microchip SAME70 micro controller.
>
> I have attached my config.h file.
>
> What am I doing wrong?
>
>