You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the fileecp.c, functions ecp_randomize_jac and ecp_randomize_mxz have a retry counter to generate a random number 1 < l < p. If the retry counter exceeds the limit, the function returns directly, without going through cleanup.
It leads to a memory leak when the RNG function fails within the loop.
These functions are called from mbedtls_ecp_mul, so also affects ECDH and ECDSA computations.
Steps to reproduce
Sample program that simulates a failing RNG function during the call to the function. Same bug occurs with a Montgomery curve (group id MBEDTLS_ECP_DP_CURVE25519)
$ valgrind --leak-check=full ./main
==66890== Memcheck, a memory error detector
==66890== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==66890== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==66890== Command: ./main
==66890==
==66890==
==66890== HEAP SUMMARY:
==66890== in use at exit: 32 bytes in 1 blocks
==66890== total heap usage: 17,066 allocs, 17,065 frees, 632,560 bytes allocated
==66890==
==66890== 32 bytes in 1 blocks are definitely lost in loss record 1 of 1
==66890== at 0x4838B65: calloc (vg_replace_malloc.c:762)
==66890== by 0x10954C: mbedtls_mpi_grow (in /home/user/mbedtls/build/main)
==66890== by 0x10E011: mbedtls_mpi_fill_random (in /home/user/mbedtls/build/main)
==66890== by 0x111BF1: ecp_randomize_jac (in /home/user/mbedtls/build/main)
==66890== by 0x11273C: ecp_mul_comb_after_precomp (in /home/user/mbedtls/build/main)
==66890== by 0x1129AD: ecp_mul_comb (in /home/user/mbedtls/build/main)
==66890== by 0x11351A: mbedtls_ecp_mul_restartable (in /home/user/mbedtls/build/main)
==66890== by 0x113582: mbedtls_ecp_mul (in /home/user/mbedtls/build/main)
==66890== by 0x1092FE: main (in /home/user/mbedtls/build/main)
==66890==
==66890== LEAK SUMMARY:
==66890== definitely lost: 32 bytes in 1 blocks
==66890== indirectly lost: 0 bytes in 0 blocks
==66890== possibly lost: 0 bytes in 0 blocks
==66890== still reachable: 0 bytes in 0 blocks
==66890== suppressed: 0 bytes in 0 blocks
==66890==
==66890== For lists of detected and suppressed errors, rerun with: -s
==66890== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
The text was updated successfully, but these errors were encountered:
Description
Bug
In the file
ecp.c
, functionsecp_randomize_jac
andecp_randomize_mxz
have a retry counter to generate a random number1 < l < p
. If the retry counter exceeds the limit, the function returns directly, without going through cleanup.It leads to a memory leak when the RNG function fails within the loop.
These functions are called from
mbedtls_ecp_mul
, so also affects ECDH and ECDSA computations.Steps to reproduce
Sample program that simulates a failing RNG function during the call to the function. Same bug occurs with a Montgomery curve (group id
MBEDTLS_ECP_DP_CURVE25519
)Valgrind report for memory leak check:
The text was updated successfully, but these errors were encountered: