Move psa_crypto_init() after other init calls
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
diff --git a/programs/x509/cert_req.c b/programs/x509/cert_req.c
index 2f4bd0e..a3fd6e2 100644
--- a/programs/x509/cert_req.c
+++ b/programs/x509/cert_req.c
@@ -155,6 +155,15 @@
mbedtls_ctr_drbg_context ctr_drbg;
const char *pers = "csr example app";
+ /*
+ * Set to sane values
+ */
+ mbedtls_x509write_csr_init(&req);
+ mbedtls_pk_init(&key);
+ mbedtls_ctr_drbg_init(&ctr_drbg);
+ memset(buf, 0, sizeof(buf));
+ mbedtls_entropy_init(&entropy);
+
#if defined(MBEDTLS_USE_PSA_CRYPTO)
psa_status_t status = psa_crypto_init();
if (status != PSA_SUCCESS) {
@@ -164,14 +173,6 @@
}
#endif /* MBEDTLS_USE_PSA_CRYPTO */
- /*
- * Set to sane values
- */
- mbedtls_x509write_csr_init(&req);
- mbedtls_pk_init(&key);
- mbedtls_ctr_drbg_init(&ctr_drbg);
- memset(buf, 0, sizeof(buf));
-
if (argc < 2) {
usage:
mbedtls_printf(USAGE);
@@ -303,7 +304,6 @@
mbedtls_printf(" . Seeding the random number generator...");
fflush(stdout);
- mbedtls_entropy_init(&entropy);
if ((ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
(const unsigned char *) pers,
strlen(pers))) != 0) {