mirror of
https://github.com/cuberite/polarssl.git
synced 2025-08-20 19:16:32 -04:00
Merge pull request #7488 from mprse/psa_init_in_programs_backport
Backport 2.28: Init PSA in ssl and x509 programs
This commit is contained in:
commit
a31c6eb509
3
ChangeLog.d/programs_psa_fix.txt
Normal file
3
ChangeLog.d/programs_psa_fix.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Bugfix
|
||||||
|
* Fix missing PSA initialization in sample programs when
|
||||||
|
MBEDTLS_USE_PSA_CRYPTO is enabled.
|
@ -77,6 +77,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||||
mbedtls_entropy_init(&entropy);
|
mbedtls_entropy_init(&entropy);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
|
if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
|
||||||
(const unsigned char *) pers, strlen(pers)) != 0) {
|
(const unsigned char *) pers, strlen(pers)) != 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -184,6 +191,9 @@ exit:
|
|||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_ssl_config_free(&conf);
|
mbedtls_ssl_config_free(&conf);
|
||||||
mbedtls_ssl_free(&ssl);
|
mbedtls_ssl_free(&ssl);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
(void) Data;
|
(void) Data;
|
||||||
|
@ -61,6 +61,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||||
mbedtls_entropy_init(&entropy);
|
mbedtls_entropy_init(&entropy);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
srand(1);
|
srand(1);
|
||||||
if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
|
if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
|
||||||
(const unsigned char *) pers, strlen(pers)) != 0) {
|
(const unsigned char *) pers, strlen(pers)) != 0) {
|
||||||
@ -119,6 +126,9 @@ exit:
|
|||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_ssl_config_free(&conf);
|
mbedtls_ssl_config_free(&conf);
|
||||||
mbedtls_ssl_free(&ssl);
|
mbedtls_ssl_free(&ssl);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
(void) Data;
|
(void) Data;
|
||||||
|
@ -74,6 +74,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||||||
mbedtls_entropy_init(&entropy);
|
mbedtls_entropy_init(&entropy);
|
||||||
mbedtls_ssl_cookie_init(&cookie_ctx);
|
mbedtls_ssl_cookie_init(&cookie_ctx);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
|
if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
|
||||||
(const unsigned char *) pers, strlen(pers)) != 0) {
|
(const unsigned char *) pers, strlen(pers)) != 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -152,9 +159,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||||||
exit:
|
exit:
|
||||||
mbedtls_ssl_cookie_free(&cookie_ctx);
|
mbedtls_ssl_cookie_free(&cookie_ctx);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
|
||||||
|
mbedtls_pk_free(&pkey);
|
||||||
|
mbedtls_x509_crt_free(&srvcert);
|
||||||
|
#endif
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_ssl_config_free(&conf);
|
mbedtls_ssl_config_free(&conf);
|
||||||
mbedtls_ssl_free(&ssl);
|
mbedtls_ssl_free(&ssl);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
(void) Data;
|
(void) Data;
|
||||||
|
@ -18,6 +18,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_pk_init(&pk);
|
mbedtls_pk_init(&pk);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
ret = mbedtls_pk_parse_key(&pk, Data, Size, NULL, 0);
|
ret = mbedtls_pk_parse_key(&pk, Data, Size, NULL, 0);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
#if defined(MBEDTLS_RSA_C)
|
#if defined(MBEDTLS_RSA_C)
|
||||||
@ -63,6 +71,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
exit:
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
mbedtls_pk_free(&pk);
|
mbedtls_pk_free(&pk);
|
||||||
#else
|
#else
|
||||||
(void) Data;
|
(void) Data;
|
||||||
|
@ -9,6 +9,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||||||
mbedtls_pk_context pk;
|
mbedtls_pk_context pk;
|
||||||
|
|
||||||
mbedtls_pk_init(&pk);
|
mbedtls_pk_init(&pk);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
ret = mbedtls_pk_parse_public_key(&pk, Data, Size);
|
ret = mbedtls_pk_parse_public_key(&pk, Data, Size);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
#if defined(MBEDTLS_RSA_C)
|
#if defined(MBEDTLS_RSA_C)
|
||||||
@ -64,6 +70,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
exit:
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
mbedtls_pk_free(&pk);
|
mbedtls_pk_free(&pk);
|
||||||
#else
|
#else
|
||||||
(void) Data;
|
(void) Data;
|
||||||
|
@ -89,6 +89,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||||||
mbedtls_ssl_ticket_init(&ticket_ctx);
|
mbedtls_ssl_ticket_init(&ticket_ctx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
|
if (mbedtls_ctr_drbg_seed(&ctr_drbg, dummy_entropy, &entropy,
|
||||||
(const unsigned char *) pers, strlen(pers)) != 0) {
|
(const unsigned char *) pers, strlen(pers)) != 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -195,8 +202,14 @@ exit:
|
|||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_ssl_config_free(&conf);
|
mbedtls_ssl_config_free(&conf);
|
||||||
|
#if defined(MBEDTLS_X509_CRT_PARSE_C) && defined(MBEDTLS_PEM_PARSE_C)
|
||||||
|
mbedtls_x509_crt_free(&srvcert);
|
||||||
|
mbedtls_pk_free(&pkey);
|
||||||
|
#endif
|
||||||
mbedtls_ssl_free(&ssl);
|
mbedtls_ssl_free(&ssl);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
(void) Data;
|
(void) Data;
|
||||||
(void) Size;
|
(void) Size;
|
||||||
|
@ -9,10 +9,20 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||||||
unsigned char buf[4096];
|
unsigned char buf[4096];
|
||||||
|
|
||||||
mbedtls_x509_crl_init(&crl);
|
mbedtls_x509_crl_init(&crl);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
ret = mbedtls_x509_crl_parse(&crl, Data, Size);
|
ret = mbedtls_x509_crl_parse(&crl, Data, Size);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = mbedtls_x509_crl_info((char *) buf, sizeof(buf) - 1, " ", &crl);
|
ret = mbedtls_x509_crl_info((char *) buf, sizeof(buf) - 1, " ", &crl);
|
||||||
}
|
}
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
exit:
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
mbedtls_x509_crl_free(&crl);
|
mbedtls_x509_crl_free(&crl);
|
||||||
#else
|
#else
|
||||||
(void) Data;
|
(void) Data;
|
||||||
|
@ -9,10 +9,20 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||||||
unsigned char buf[4096];
|
unsigned char buf[4096];
|
||||||
|
|
||||||
mbedtls_x509_crt_init(&crt);
|
mbedtls_x509_crt_init(&crt);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
ret = mbedtls_x509_crt_parse(&crt, Data, Size);
|
ret = mbedtls_x509_crt_parse(&crt, Data, Size);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = mbedtls_x509_crt_info((char *) buf, sizeof(buf) - 1, " ", &crt);
|
ret = mbedtls_x509_crt_info((char *) buf, sizeof(buf) - 1, " ", &crt);
|
||||||
}
|
}
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
exit:
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
mbedtls_x509_crt_free(&crt);
|
mbedtls_x509_crt_free(&crt);
|
||||||
#else
|
#else
|
||||||
(void) Data;
|
(void) Data;
|
||||||
|
@ -9,10 +9,20 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
|||||||
unsigned char buf[4096];
|
unsigned char buf[4096];
|
||||||
|
|
||||||
mbedtls_x509_csr_init(&csr);
|
mbedtls_x509_csr_init(&csr);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
ret = mbedtls_x509_csr_parse(&csr, Data, Size);
|
ret = mbedtls_x509_csr_parse(&csr, Data, Size);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = mbedtls_x509_csr_info((char *) buf, sizeof(buf) - 1, " ", &csr);
|
ret = mbedtls_x509_csr_info((char *) buf, sizeof(buf) - 1, " ", &csr);
|
||||||
}
|
}
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
exit:
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
mbedtls_x509_csr_free(&csr);
|
mbedtls_x509_csr_free(&csr);
|
||||||
#else
|
#else
|
||||||
(void) Data;
|
(void) Data;
|
||||||
|
@ -204,6 +204,15 @@ int main(int argc, char *argv[])
|
|||||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
usage:
|
usage:
|
||||||
mbedtls_printf(USAGE);
|
mbedtls_printf(USAGE);
|
||||||
@ -411,6 +420,9 @@ exit:
|
|||||||
mbedtls_pk_free(&key);
|
mbedtls_pk_free(&key);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" + Press Enter to exit this program.\n");
|
mbedtls_printf(" + Press Enter to exit this program.\n");
|
||||||
|
@ -91,6 +91,15 @@ int main(int argc, char *argv[])
|
|||||||
mbedtls_pk_init(&pk);
|
mbedtls_pk_init(&pk);
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
mbedtls_mpi_init(&N); mbedtls_mpi_init(&P); mbedtls_mpi_init(&Q);
|
mbedtls_mpi_init(&N); mbedtls_mpi_init(&P); mbedtls_mpi_init(&Q);
|
||||||
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);
|
||||||
@ -275,6 +284,9 @@ cleanup:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
mbedtls_pk_free(&pk);
|
mbedtls_pk_free(&pk);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
mbedtls_mpi_free(&N); mbedtls_mpi_free(&P); mbedtls_mpi_free(&Q);
|
mbedtls_mpi_free(&N); mbedtls_mpi_free(&P); mbedtls_mpi_free(&Q);
|
||||||
mbedtls_mpi_free(&D); mbedtls_mpi_free(&E); mbedtls_mpi_free(&DP);
|
mbedtls_mpi_free(&D); mbedtls_mpi_free(&E); mbedtls_mpi_free(&DP);
|
||||||
mbedtls_mpi_free(&DQ); mbedtls_mpi_free(&QP);
|
mbedtls_mpi_free(&DQ); mbedtls_mpi_free(&QP);
|
||||||
|
@ -205,6 +205,15 @@ int main(int argc, char *argv[])
|
|||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
mbedtls_mpi_init(&N); mbedtls_mpi_init(&P); mbedtls_mpi_init(&Q);
|
mbedtls_mpi_init(&N); mbedtls_mpi_init(&P); mbedtls_mpi_init(&Q);
|
||||||
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);
|
||||||
@ -400,6 +409,9 @@ exit:
|
|||||||
mbedtls_mpi_free(&DQ); mbedtls_mpi_free(&QP);
|
mbedtls_mpi_free(&DQ); mbedtls_mpi_free(&QP);
|
||||||
|
|
||||||
mbedtls_pk_free(&key);
|
mbedtls_pk_free(&key);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" + Press Enter to exit this program.\n");
|
mbedtls_printf(" + Press Enter to exit this program.\n");
|
||||||
|
@ -71,6 +71,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
memset(result, 0, sizeof(result));
|
memset(result, 0, sizeof(result));
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
mbedtls_printf("usage: mbedtls_pk_decrypt <key_file>\n");
|
mbedtls_printf("usage: mbedtls_pk_decrypt <key_file>\n");
|
||||||
|
|
||||||
@ -142,6 +151,9 @@ exit:
|
|||||||
mbedtls_pk_free(&pk);
|
mbedtls_pk_free(&pk);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ERROR_C)
|
#if defined(MBEDTLS_ERROR_C)
|
||||||
if (exit_code != MBEDTLS_EXIT_SUCCESS) {
|
if (exit_code != MBEDTLS_EXIT_SUCCESS) {
|
||||||
|
@ -67,6 +67,15 @@ int main(int argc, char *argv[])
|
|||||||
mbedtls_entropy_init(&entropy);
|
mbedtls_entropy_init(&entropy);
|
||||||
mbedtls_pk_init(&pk);
|
mbedtls_pk_init(&pk);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
mbedtls_printf("usage: mbedtls_pk_encrypt <key_file> <string of max 100 characters>\n");
|
mbedtls_printf("usage: mbedtls_pk_encrypt <key_file> <string of max 100 characters>\n");
|
||||||
|
|
||||||
@ -144,6 +153,9 @@ exit:
|
|||||||
mbedtls_pk_free(&pk);
|
mbedtls_pk_free(&pk);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ERROR_C)
|
#if defined(MBEDTLS_ERROR_C)
|
||||||
if (exit_code != MBEDTLS_EXIT_SUCCESS) {
|
if (exit_code != MBEDTLS_EXIT_SUCCESS) {
|
||||||
|
@ -66,6 +66,15 @@ int main(int argc, char *argv[])
|
|||||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||||
mbedtls_pk_init(&pk);
|
mbedtls_pk_init(&pk);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
mbedtls_printf("usage: mbedtls_pk_sign <key_file> <filename>\n");
|
mbedtls_printf("usage: mbedtls_pk_sign <key_file> <filename>\n");
|
||||||
|
|
||||||
@ -141,6 +150,9 @@ exit:
|
|||||||
mbedtls_pk_free(&pk);
|
mbedtls_pk_free(&pk);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ERROR_C)
|
#if defined(MBEDTLS_ERROR_C)
|
||||||
if (exit_code != MBEDTLS_EXIT_SUCCESS) {
|
if (exit_code != MBEDTLS_EXIT_SUCCESS) {
|
||||||
|
@ -58,6 +58,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
mbedtls_pk_init(&pk);
|
mbedtls_pk_init(&pk);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
mbedtls_printf("usage: mbedtls_pk_verify <key_file> <filename>\n");
|
mbedtls_printf("usage: mbedtls_pk_verify <key_file> <filename>\n");
|
||||||
|
|
||||||
@ -117,6 +126,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_pk_free(&pk);
|
mbedtls_pk_free(&pk);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ERROR_C)
|
#if defined(MBEDTLS_ERROR_C)
|
||||||
if (exit_code != MBEDTLS_EXIT_SUCCESS) {
|
if (exit_code != MBEDTLS_EXIT_SUCCESS) {
|
||||||
|
@ -67,6 +67,15 @@ int main(int argc, char *argv[])
|
|||||||
mbedtls_pk_init(&pk);
|
mbedtls_pk_init(&pk);
|
||||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
mbedtls_printf("usage: rsa_sign_pss <key_file> <filename>\n");
|
mbedtls_printf("usage: rsa_sign_pss <key_file> <filename>\n");
|
||||||
|
|
||||||
@ -149,6 +158,9 @@ exit:
|
|||||||
mbedtls_pk_free(&pk);
|
mbedtls_pk_free(&pk);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" + Press Enter to exit this program.\n");
|
mbedtls_printf(" + Press Enter to exit this program.\n");
|
||||||
|
@ -61,6 +61,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
mbedtls_pk_init(&pk);
|
mbedtls_pk_init(&pk);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
mbedtls_printf("usage: rsa_verify_pss <key_file> <filename>\n");
|
mbedtls_printf("usage: rsa_verify_pss <key_file> <filename>\n");
|
||||||
|
|
||||||
@ -127,6 +136,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_pk_free(&pk);
|
mbedtls_pk_free(&pk);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" + Press Enter to exit this program.\n");
|
mbedtls_printf(" + Press Enter to exit this program.\n");
|
||||||
|
@ -113,11 +113,21 @@ int main(int argc, char *argv[])
|
|||||||
mbedtls_ssl_config_init(&conf);
|
mbedtls_ssl_config_init(&conf);
|
||||||
mbedtls_x509_crt_init(&cacert);
|
mbedtls_x509_crt_init(&cacert);
|
||||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||||
|
mbedtls_entropy_init(&entropy);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
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) {
|
||||||
@ -324,12 +334,14 @@ exit:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
mbedtls_net_free(&server_fd);
|
mbedtls_net_free(&server_fd);
|
||||||
|
|
||||||
mbedtls_x509_crt_free(&cacert);
|
mbedtls_x509_crt_free(&cacert);
|
||||||
mbedtls_ssl_free(&ssl);
|
mbedtls_ssl_free(&ssl);
|
||||||
mbedtls_ssl_config_free(&conf);
|
mbedtls_ssl_config_free(&conf);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" + Press Enter to exit this program.\n");
|
mbedtls_printf(" + Press Enter to exit this program.\n");
|
||||||
|
@ -124,6 +124,16 @@ int main(void)
|
|||||||
mbedtls_entropy_init(&entropy);
|
mbedtls_entropy_init(&entropy);
|
||||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(MBEDTLS_DEBUG_C)
|
#if defined(MBEDTLS_DEBUG_C)
|
||||||
mbedtls_debug_set_threshold(DEBUG_LEVEL);
|
mbedtls_debug_set_threshold(DEBUG_LEVEL);
|
||||||
#endif
|
#endif
|
||||||
@ -394,6 +404,9 @@ exit:
|
|||||||
#endif
|
#endif
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
printf(" Press Enter to exit this program.\n");
|
printf(" Press Enter to exit this program.\n");
|
||||||
|
@ -179,8 +179,16 @@ int main(void)
|
|||||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
mbedtls_x509_crt_init(&ca);
|
mbedtls_x509_crt_init(&ca);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mbedtls_entropy_init(&entropy);
|
mbedtls_entropy_init(&entropy);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
|
if (mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||||
(const unsigned char *) pers, strlen(pers)) != 0) {
|
(const unsigned char *) pers, strlen(pers)) != 0) {
|
||||||
ret = ctr_drbg_seed_failed;
|
ret = ctr_drbg_seed_failed;
|
||||||
@ -266,7 +274,6 @@ int main(void)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_net_free(&server_fd);
|
mbedtls_net_free(&server_fd);
|
||||||
|
|
||||||
mbedtls_ssl_free(&ssl);
|
mbedtls_ssl_free(&ssl);
|
||||||
mbedtls_ssl_config_free(&conf);
|
mbedtls_ssl_config_free(&conf);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
@ -274,6 +281,9 @@ exit:
|
|||||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
mbedtls_x509_crt_free(&ca);
|
mbedtls_x509_crt_free(&ca);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
mbedtls_exit(ret);
|
mbedtls_exit(ret);
|
||||||
}
|
}
|
||||||
|
@ -95,11 +95,21 @@ int main(void)
|
|||||||
mbedtls_ssl_config_init(&conf);
|
mbedtls_ssl_config_init(&conf);
|
||||||
mbedtls_x509_crt_init(&cacert);
|
mbedtls_x509_crt_init(&cacert);
|
||||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||||
|
mbedtls_entropy_init(&entropy);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
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) {
|
||||||
@ -274,12 +284,14 @@ exit:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
mbedtls_net_free(&server_fd);
|
mbedtls_net_free(&server_fd);
|
||||||
|
|
||||||
mbedtls_x509_crt_free(&cacert);
|
mbedtls_x509_crt_free(&cacert);
|
||||||
mbedtls_ssl_free(&ssl);
|
mbedtls_ssl_free(&ssl);
|
||||||
mbedtls_ssl_config_free(&conf);
|
mbedtls_ssl_config_free(&conf);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" + Press Enter to exit this program.\n");
|
mbedtls_printf(" + Press Enter to exit this program.\n");
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include MBEDTLS_CONFIG_FILE
|
#include MBEDTLS_CONFIG_FILE
|
||||||
#endif
|
#endif
|
||||||
#include "mbedtls/debug.h"
|
#include "mbedtls/debug.h"
|
||||||
|
#include "mbedtls/platform.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -939,6 +940,15 @@ int main(int argc, char *argv[])
|
|||||||
size_t ssl_max_len = SSL_INIT_LEN;
|
size_t ssl_max_len = SSL_INIT_LEN;
|
||||||
size_t ssl_len = 0;
|
size_t ssl_len = 0;
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
return MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
/* The 'b64_file' is opened when parsing arguments to check that the
|
/* The 'b64_file' is opened when parsing arguments to check that the
|
||||||
* file name is correct */
|
* file name is correct */
|
||||||
parse_arguments(argc, argv);
|
parse_arguments(argc, argv);
|
||||||
@ -1007,6 +1017,10 @@ int main(int argc, char *argv[])
|
|||||||
printf("Finished. No valid base64 code found\n");
|
printf("Finished. No valid base64 code found\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +109,15 @@ int main(void)
|
|||||||
mbedtls_x509_crt_init(&srvcert);
|
mbedtls_x509_crt_init(&srvcert);
|
||||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
signal(SIGCHLD, SIG_IGN);
|
signal(SIGCHLD, SIG_IGN);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -369,13 +378,15 @@ int main(void)
|
|||||||
exit:
|
exit:
|
||||||
mbedtls_net_free(&client_fd);
|
mbedtls_net_free(&client_fd);
|
||||||
mbedtls_net_free(&listen_fd);
|
mbedtls_net_free(&listen_fd);
|
||||||
|
|
||||||
mbedtls_x509_crt_free(&srvcert);
|
mbedtls_x509_crt_free(&srvcert);
|
||||||
mbedtls_pk_free(&pkey);
|
mbedtls_pk_free(&pkey);
|
||||||
mbedtls_ssl_free(&ssl);
|
mbedtls_ssl_free(&ssl);
|
||||||
mbedtls_ssl_config_free(&conf);
|
mbedtls_ssl_config_free(&conf);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" Press Enter to exit this program.\n");
|
mbedtls_printf(" Press Enter to exit this program.\n");
|
||||||
|
@ -366,6 +366,16 @@ int main(int argc, char *argv[])
|
|||||||
mbedtls_x509_crt_init(&clicert);
|
mbedtls_x509_crt_init(&clicert);
|
||||||
mbedtls_pk_init(&pkey);
|
mbedtls_pk_init(&pkey);
|
||||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||||
|
mbedtls_entropy_init(&entropy);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
usage:
|
usage:
|
||||||
@ -455,7 +465,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) {
|
||||||
@ -792,6 +801,9 @@ exit:
|
|||||||
mbedtls_ssl_config_free(&conf);
|
mbedtls_ssl_config_free(&conf);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" + Press Enter to exit this program.\n");
|
mbedtls_printf(" + Press Enter to exit this program.\n");
|
||||||
|
@ -337,6 +337,16 @@ int main(void)
|
|||||||
*/
|
*/
|
||||||
mbedtls_entropy_init(&entropy);
|
mbedtls_entropy_init(&entropy);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1. Load the certificates and private RSA key
|
* 1. Load the certificates and private RSA key
|
||||||
*/
|
*/
|
||||||
@ -477,14 +487,14 @@ exit:
|
|||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
mbedtls_ssl_config_free(&conf);
|
mbedtls_ssl_config_free(&conf);
|
||||||
|
|
||||||
mbedtls_net_free(&listen_fd);
|
mbedtls_net_free(&listen_fd);
|
||||||
|
|
||||||
mbedtls_mutex_free(&debug_mutex);
|
mbedtls_mutex_free(&debug_mutex);
|
||||||
|
|
||||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
||||||
mbedtls_memory_buffer_alloc_free();
|
mbedtls_memory_buffer_alloc_free();
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" Press Enter to exit this program.\n");
|
mbedtls_printf(" Press Enter to exit this program.\n");
|
||||||
|
@ -109,6 +109,16 @@ int main(void)
|
|||||||
mbedtls_entropy_init(&entropy);
|
mbedtls_entropy_init(&entropy);
|
||||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(MBEDTLS_DEBUG_C)
|
#if defined(MBEDTLS_DEBUG_C)
|
||||||
mbedtls_debug_set_threshold(DEBUG_LEVEL);
|
mbedtls_debug_set_threshold(DEBUG_LEVEL);
|
||||||
#endif
|
#endif
|
||||||
@ -347,7 +357,6 @@ exit:
|
|||||||
|
|
||||||
mbedtls_net_free(&client_fd);
|
mbedtls_net_free(&client_fd);
|
||||||
mbedtls_net_free(&listen_fd);
|
mbedtls_net_free(&listen_fd);
|
||||||
|
|
||||||
mbedtls_x509_crt_free(&srvcert);
|
mbedtls_x509_crt_free(&srvcert);
|
||||||
mbedtls_pk_free(&pkey);
|
mbedtls_pk_free(&pkey);
|
||||||
mbedtls_ssl_free(&ssl);
|
mbedtls_ssl_free(&ssl);
|
||||||
@ -357,6 +366,9 @@ exit:
|
|||||||
#endif
|
#endif
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" Press Enter to exit this program.\n");
|
mbedtls_printf(" Press Enter to exit this program.\n");
|
||||||
|
@ -157,6 +157,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
|
||||||
@ -165,6 +166,15 @@ int main(int argc, char *argv[])
|
|||||||
memset(&cacrl, 0, sizeof(mbedtls_x509_crl));
|
memset(&cacrl, 0, sizeof(mbedtls_x509_crl));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
usage:
|
usage:
|
||||||
mbedtls_printf(USAGE);
|
mbedtls_printf(USAGE);
|
||||||
@ -342,7 +352,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) {
|
||||||
@ -452,6 +461,9 @@ exit:
|
|||||||
#endif
|
#endif
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" + Press Enter to exit this program.\n");
|
mbedtls_printf(" + Press Enter to exit this program.\n");
|
||||||
|
@ -162,6 +162,16 @@ int main(int argc, char *argv[])
|
|||||||
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));
|
||||||
|
mbedtls_entropy_init(&entropy);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
usage:
|
usage:
|
||||||
@ -294,7 +304,6 @@ usage:
|
|||||||
mbedtls_printf(" . Seeding the random number generator...");
|
mbedtls_printf(" . 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) {
|
||||||
@ -365,6 +374,9 @@ exit:
|
|||||||
mbedtls_pk_free(&key);
|
mbedtls_pk_free(&key);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" + Press Enter to exit this program.\n");
|
mbedtls_printf(" + Press Enter to exit this program.\n");
|
||||||
|
@ -241,6 +241,15 @@ int main(int argc, char *argv[])
|
|||||||
mbedtls_x509_crt_init(&issuer_crt);
|
mbedtls_x509_crt_init(&issuer_crt);
|
||||||
memset(buf, 0, 1024);
|
memset(buf, 0, 1024);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
usage:
|
usage:
|
||||||
mbedtls_printf(USAGE);
|
mbedtls_printf(USAGE);
|
||||||
@ -717,6 +726,9 @@ exit:
|
|||||||
mbedtls_mpi_free(&serial);
|
mbedtls_mpi_free(&serial);
|
||||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||||
mbedtls_entropy_free(&entropy);
|
mbedtls_entropy_free(&entropy);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" + Press Enter to exit this program.\n");
|
mbedtls_printf(" + Press Enter to exit this program.\n");
|
||||||
|
@ -72,6 +72,15 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
mbedtls_x509_crl_init(&crl);
|
mbedtls_x509_crl_init(&crl);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
usage:
|
usage:
|
||||||
mbedtls_printf(USAGE);
|
mbedtls_printf(USAGE);
|
||||||
@ -127,6 +136,9 @@ usage:
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crl_free(&crl);
|
mbedtls_x509_crl_free(&crl);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" + Press Enter to exit this program.\n");
|
mbedtls_printf(" + Press Enter to exit this program.\n");
|
||||||
|
@ -127,6 +127,15 @@ int main(int argc, char *argv[])
|
|||||||
struct mbedtls_timing_hr_time timer;
|
struct mbedtls_timing_hr_time timer;
|
||||||
unsigned long ms;
|
unsigned long ms;
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
mbedtls_printf(USAGE);
|
mbedtls_printf(USAGE);
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -191,6 +200,9 @@ int main(int argc, char *argv[])
|
|||||||
exit_code = MBEDTLS_EXIT_SUCCESS;
|
exit_code = MBEDTLS_EXIT_SUCCESS;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
mbedtls_exit(exit_code);
|
mbedtls_exit(exit_code);
|
||||||
}
|
}
|
||||||
#endif /* necessary configuration */
|
#endif /* necessary configuration */
|
||||||
|
@ -72,6 +72,15 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
mbedtls_x509_csr_init(&csr);
|
mbedtls_x509_csr_init(&csr);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
psa_status_t status = psa_crypto_init();
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
mbedtls_fprintf(stderr, "Failed to initialize PSA Crypto implementation: %d\n",
|
||||||
|
(int) status);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
usage:
|
usage:
|
||||||
mbedtls_printf(USAGE);
|
mbedtls_printf(USAGE);
|
||||||
@ -127,6 +136,9 @@ usage:
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_csr_free(&csr);
|
mbedtls_x509_csr_free(&csr);
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
mbedtls_psa_crypto_free();
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf(" + Press Enter to exit this program.\n");
|
mbedtls_printf(" + Press Enter to exit this program.\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user