From 06b6f34e9f668e34e01e4c75bc90e6ee445cb0db Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 12 Nov 2018 17:47:48 +0000 Subject: [PATCH] Initialize PSA Crypto implementation in ssl_server2 --- programs/ssl/ssl_server2.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index efda65d23..1c6ccaef1 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -60,6 +60,10 @@ int main( void ) #include "mbedtls/debug.h" #include "mbedtls/timing.h" +#if defined(MBEDTLS_USE_PSA_CRYPTO) +#include "psa/crypto.h" +#endif + #include #include #include @@ -1238,6 +1242,9 @@ int main( int argc, char *argv[] ) int i; char *p, *q; const int *list; +#if defined(MBEDTLS_USE_PSA_CRYPTO) + psa_status_t status; +#endif #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) ); @@ -1277,6 +1284,17 @@ int main( int argc, char *argv[] ) mbedtls_ssl_cookie_init( &cookie_ctx ); #endif +#if defined(MBEDTLS_USE_PSA_CRYPTO) + 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 + #if !defined(_WIN32) /* Abort cleanly on SIGTERM and SIGINT */ signal( SIGTERM, term_handler );