mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-06-26 15:07:59 +08:00
cert_app: init entropy unconditionally
When mbedtls_entropy_free() is called without mbedtls_entropy_init() entropy is uninitialized and contains garbage which may lead to segmentation fault. Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
parent
89c636e6cf
commit
6260ee9cab
@ -162,6 +162,7 @@ int main(int argc, char *argv[])
|
|||||||
mbedtls_ssl_init(&ssl);
|
mbedtls_ssl_init(&ssl);
|
||||||
mbedtls_ssl_config_init(&conf);
|
mbedtls_ssl_config_init(&conf);
|
||||||
mbedtls_x509_crt_init(&cacert);
|
mbedtls_x509_crt_init(&cacert);
|
||||||
|
mbedtls_entropy_init(&entropy);
|
||||||
#if defined(MBEDTLS_X509_CRL_PARSE_C)
|
#if defined(MBEDTLS_X509_CRL_PARSE_C)
|
||||||
mbedtls_x509_crl_init(&cacrl);
|
mbedtls_x509_crl_init(&cacrl);
|
||||||
#else
|
#else
|
||||||
@ -347,7 +348,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 ((ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
|
if ((ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||||
(const unsigned char *) pers,
|
(const unsigned char *) pers,
|
||||||
strlen(pers))) != 0) {
|
strlen(pers))) != 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user