1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-30 22:43:08 +03:00

Init PSA in ssl and x509 programs

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
Przemek Stekiel
2023-04-14 09:26:39 +02:00
parent b5b0649e77
commit d381d2d5fc
15 changed files with 141 additions and 0 deletions

View File

@ -101,6 +101,16 @@ int main(int argc, char *argv[])
((void) argc); ((void) argc);
((void) argv); ((void) argv);
#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

View File

@ -111,6 +111,16 @@ int main(void)
mbedtls_ssl_cache_context cache; mbedtls_ssl_cache_context cache;
#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);
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
goto exit;
}
#endif /* MBEDTLS_USE_PSA_CRYPTO */
mbedtls_net_init(&listen_fd); mbedtls_net_init(&listen_fd);
mbedtls_net_init(&client_fd); mbedtls_net_init(&client_fd);
mbedtls_ssl_init(&ssl); mbedtls_ssl_init(&ssl);

View File

@ -170,6 +170,16 @@ int main(void)
mbedtls_ssl_config conf; mbedtls_ssl_config conf;
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 */
/* /*
* 0. Initialize and setup stuff * 0. Initialize and setup stuff
*/ */

View File

@ -87,6 +87,15 @@ int main(void)
mbedtls_debug_set_threshold(DEBUG_LEVEL); mbedtls_debug_set_threshold(DEBUG_LEVEL);
#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 */
/* /*
* 0. Initialize the RNG and the session data * 0. Initialize the RNG and the session data
*/ */

View File

@ -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);

View File

@ -100,6 +100,15 @@ int main(void)
mbedtls_x509_crt srvcert; mbedtls_x509_crt srvcert;
mbedtls_pk_context pkey; mbedtls_pk_context pkey;
#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_net_init(&listen_fd); mbedtls_net_init(&listen_fd);
mbedtls_net_init(&client_fd); mbedtls_net_init(&client_fd);
mbedtls_ssl_init(&ssl); mbedtls_ssl_init(&ssl);

View File

@ -355,6 +355,15 @@ int main(int argc, char *argv[])
char *p, *q; char *p, *q;
const int *list; const int *list;
#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 */
/* /*
* Make sure memory references are valid in case we exit early. * Make sure memory references are valid in case we exit early.
*/ */

View File

@ -311,6 +311,16 @@ int main(void)
mbedtls_ssl_cache_context cache; mbedtls_ssl_cache_context cache;
#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);
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
goto exit;
}
#endif /* MBEDTLS_USE_PSA_CRYPTO */
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
mbedtls_memory_buffer_alloc_init(alloc_buf, sizeof(alloc_buf)); mbedtls_memory_buffer_alloc_init(alloc_buf, sizeof(alloc_buf));
#endif #endif

View File

@ -97,6 +97,16 @@ int main(void)
mbedtls_ssl_cache_context cache; mbedtls_ssl_cache_context cache;
#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);
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
goto exit;
}
#endif /* MBEDTLS_USE_PSA_CRYPTO */
mbedtls_net_init(&listen_fd); mbedtls_net_init(&listen_fd);
mbedtls_net_init(&client_fd); mbedtls_net_init(&client_fd);
mbedtls_ssl_init(&ssl); mbedtls_ssl_init(&ssl);

View File

@ -149,6 +149,15 @@ int main(int argc, char *argv[])
char *p, *q; char *p, *q;
const char *pers = "cert_app"; const char *pers = "cert_app";
#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 */
/* /*
* Set to sane values * Set to sane values
*/ */

View File

@ -155,6 +155,15 @@ int main(int argc, char *argv[])
mbedtls_ctr_drbg_context ctr_drbg; mbedtls_ctr_drbg_context ctr_drbg;
const char *pers = "csr example app"; const char *pers = "csr example app";
#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 */
/* /*
* Set to sane values * Set to sane values
*/ */

View File

@ -226,6 +226,15 @@ int main(int argc, char *argv[])
mbedtls_ctr_drbg_context ctr_drbg; mbedtls_ctr_drbg_context ctr_drbg;
const char *pers = "crt example app"; const char *pers = "crt example app";
#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 */
/* /*
* Set to sane values * Set to sane values
*/ */

View File

@ -67,6 +67,15 @@ int main(int argc, char *argv[])
int i; int i;
char *p, *q; char *p, *q;
#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 */
/* /*
* Set to sane values * Set to sane values
*/ */

View File

@ -132,6 +132,15 @@ int main(int argc, char *argv[])
goto exit; goto exit;
} }
#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 */
opt.filenames = NULL; opt.filenames = NULL;
opt.iterations = DFL_ITERATIONS; opt.iterations = DFL_ITERATIONS;
opt.prime_cache = DFL_PRIME_CACHE; opt.prime_cache = DFL_PRIME_CACHE;

View File

@ -67,6 +67,15 @@ int main(int argc, char *argv[])
int i; int i;
char *p, *q; char *p, *q;
#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 */
/* /*
* Set to sane values * Set to sane values
*/ */