diff --git a/source/core_pkcs11.c b/source/core_pkcs11.c index 15350bd8..00d49282 100644 --- a/source/core_pkcs11.c +++ b/source/core_pkcs11.c @@ -32,7 +32,6 @@ #include #include - /** * @file core_pkcs11.c * @brief corePKCS11 Interface. diff --git a/source/portable/mbedtls/core_pkcs11_mbedtls.c b/source/portable/mbedtls/core_pkcs11_mbedtls.c index 79853c2d..a1fa0a65 100644 --- a/source/portable/mbedtls/core_pkcs11_mbedtls.c +++ b/source/portable/mbedtls/core_pkcs11_mbedtls.c @@ -42,7 +42,13 @@ */ #define MBEDTLS_ALLOW_PRIVATE_ACCESS -/* mbedTLS includes. */ +/* MbedTLS includes. */ +#if defined( MBEDTLS_CONFIG_FILE ) + #include MBEDTLS_CONFIG_FILE +#else + #include "mbedtls/mbedtls_config.h" +#endif + #include "mbedtls/pk.h" #include "mbedtls/x509_crt.h" #include "mbedtls/ctr_drbg.h" @@ -496,19 +502,24 @@ static CK_RV prvMbedTLS_Initialize( void ) if( lMbedTLSResult != PSA_SUCCESS ) { LogError( ( "Could not initialize PKCS #11. Failed to initialize PSA: MBedTLS error = %s : %s.", - mbedtlsHighLevelCodeOrDefault( lMbedTLSResult ), - mbedtlsLowLevelCodeOrDefault( lMbedTLSResult ) ) ); + mbedtlsHighLevelCodeOrDefault( lMbedTLSResult ), + mbedtlsLowLevelCodeOrDefault( lMbedTLSResult ) ) ); xResult = CKR_FUNCTION_FAILED; + /* MISRA Ref 10.5.1 [Essential type casting] */ + /* More details at: https://github.com/FreeRTOS/corePKCS11/blob/main/MISRA.md#rule-105 */ + /* coverity[misra_c_2012_rule_10_5_violation] */ + xP11Context.xIsInitialized = ( CK_BBOOL ) CK_FALSE; + } + else{ + LogDebug( ( "MbedTLS PSA module was successfully initialized." ) ); } - else #endif /* MBEDTLS_USE_PSA_CRYPTO */ - { - /* MISRA Ref 10.5.1 [Essential type casting] */ - /* More details at: https://github.com/FreeRTOS/corePKCS11/blob/main/MISRA.md#rule-105 */ - /* coverity[misra_c_2012_rule_10_5_violation] */ - xP11Context.xIsInitialized = ( CK_BBOOL ) CK_TRUE; - LogDebug( ( "PKCS #11 module was successfully initialized." ) ); - } + + /* MISRA Ref 10.5.1 [Essential type casting] */ + /* More details at: https://github.com/FreeRTOS/corePKCS11/blob/main/MISRA.md#rule-105 */ + /* coverity[misra_c_2012_rule_10_5_violation] */ + xP11Context.xIsInitialized = ( CK_BBOOL ) CK_TRUE; + LogDebug( ( "PKCS #11 module was successfully initialized." ) ); } return xResult; diff --git a/source/portable/os/freertos_winsim/core_pkcs11_pal.c b/source/portable/os/freertos_winsim/core_pkcs11_pal.c index 5b9c7db4..1beddbe0 100644 --- a/source/portable/os/freertos_winsim/core_pkcs11_pal.c +++ b/source/portable/os/freertos_winsim/core_pkcs11_pal.c @@ -32,26 +32,25 @@ /*-----------------------------------------------------------*/ +/* System Includes */ +#include +#include + #ifdef WIN32 - #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN + #ifdef WIN32_LEAN_AND_MEAN + #include + #else + #include #endif /* WIN32_LEAN_AND_MEAN */ +#endif /* WIN32 */ - #include - #include -#endif - - +/* FreeRTOS Includes */ #include "FreeRTOS.h" + +/* corePKCS11 Includes */ #include "core_pkcs11.h" #include "core_pkcs11_config.h" #include "core_pkcs11_config_defaults.h" - - -/* C runtime includes. */ -#include -#include - #include "core_pkcs11_pal_utils.h" /*-----------------------------------------------------------*/