Skip to content

Commit

Permalink
Merge pull request #8818 from forkiee2/mbedtls-2.28
Browse files Browse the repository at this point in the history
Backport 2.28: move entropy init prior arguments number recognition
  • Loading branch information
gilles-peskine-arm authored Feb 14, 2024
2 parents 75c8e61 + c609654 commit 039c903
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ChangeLog.d/gen-key-segfault.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix
* Avoid segmentation fault caused by releasing not initialized
entropy resource in gen_key example. Fixes #8809.
2 changes: 1 addition & 1 deletion programs/pkey/gen_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(&DQ); mbedtls_mpi_init(&QP);

mbedtls_entropy_init(&entropy);
mbedtls_pk_init(&key);
mbedtls_ctr_drbg_init(&ctr_drbg);
memset(buf, 0, sizeof(buf));
Expand Down Expand Up @@ -275,7 +276,6 @@ int main(int argc, char *argv[])
mbedtls_printf("\n . Seeding the random number generator...");
fflush(stdout);

mbedtls_entropy_init(&entropy);
#if !defined(_WIN32) && defined(MBEDTLS_FS_IO)
if (opt.use_dev_random) {
if ((ret = mbedtls_entropy_add_source(&entropy, dev_random_entropy_poll,
Expand Down

0 comments on commit 039c903

Please sign in to comment.