mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-10-17 04:51:22 +03:00
move entropy init prior arguments number recognition
Signed-off-by: PiotrBzdrega <piotrbzdrega@yandex.com>
This commit is contained in:
3
ChangeLog.d/gen-key-segfault.txt
Normal file
3
ChangeLog.d/gen-key-segfault.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Bugfix
|
||||||
|
* Avoid segmentation fault caused by releasing not initialized
|
||||||
|
entropy resource in gen_key example. Fixes #8809
|
@@ -188,6 +188,7 @@ int main(int argc, char *argv[])
|
|||||||
mbedtls_mpi_init(&D); mbedtls_mpi_init(&E); mbedtls_mpi_init(&DP);
|
mbedtls_mpi_init(&D); mbedtls_mpi_init(&E); mbedtls_mpi_init(&DP);
|
||||||
mbedtls_mpi_init(&DQ); mbedtls_mpi_init(&QP);
|
mbedtls_mpi_init(&DQ); mbedtls_mpi_init(&QP);
|
||||||
|
|
||||||
|
mbedtls_entropy_init(&entropy);
|
||||||
mbedtls_pk_init(&key);
|
mbedtls_pk_init(&key);
|
||||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
@@ -275,7 +276,6 @@ usage:
|
|||||||
mbedtls_printf("\n . Seeding the random number generator...");
|
mbedtls_printf("\n . Seeding the random number generator...");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
mbedtls_entropy_init(&entropy);
|
|
||||||
#if !defined(_WIN32) && defined(MBEDTLS_FS_IO)
|
#if !defined(_WIN32) && defined(MBEDTLS_FS_IO)
|
||||||
if (opt.use_dev_random) {
|
if (opt.use_dev_random) {
|
||||||
if ((ret = mbedtls_entropy_add_source(&entropy, dev_random_entropy_poll,
|
if ((ret = mbedtls_entropy_add_source(&entropy, dev_random_entropy_poll,
|
||||||
|
Reference in New Issue
Block a user