From d2329791aa7e9e530b04dc251deaa3d50ede6473 Mon Sep 17 00:00:00 2001 From: johnrhen <90864038+johnrhen@users.noreply.github.com> Date: Wed, 24 Nov 2021 12:50:15 -0800 Subject: Fix PKCS11 demo failures (#722) * Fix build errors from improper core_pkcs11_pal paths * Runtime failure fixes * Runtime PKCS11 demo failure fixes Co-authored-by: Shivangi <66447522+gshvang@users.noreply.github.com> --- .../WIN32.vcxproj | 6 ++++-- .../WIN32.vcxproj.filters | 12 +++++++++--- .../pkcs11_demo_setup.py | 4 ++-- .../Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj | 6 ++++-- .../corePKCS11_Windows_Simulator/WIN32.vcxproj.filters | 14 +++++++++++--- .../Demo/corePKCS11_Windows_Simulator/examples/objects.c | 8 ++++---- 6 files changed, 34 insertions(+), 16 deletions(-) diff --git a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj index 703dc2a0a..c98aceb67 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj +++ b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj @@ -58,7 +58,7 @@ Disabled - ..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\FreeRTOS-Plus\Source\Utilities\logging;..\coreMQTT_Windows_Simulator\Common;..\coreMQTT_Windows_Simulator\common\WinPCap;..\..\..\FreeRTOS\Source\include;..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\Source\corePKCS11\source\include;..\..\Source\corePKCS11\source\dependency\3rdparty\pkcs11;..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\Source\Utilities\backoff_algorithm\source\include;..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp;..\..\Source\Application-Protocols\network_transport\using_mbedtls_pkcs11;..\..\Source\Utilities\mbedtls_freertos;..\..\Source\mbedtls_utils;..\..\ThirdParty\mbedtls\include;.;%(AdditionalIncludeDirectories) + ..\..\Source\FreeRTOS-Plus-Trace\Include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;..\..\..\FreeRTOS-Plus\Source\Utilities\logging;..\coreMQTT_Windows_Simulator\Common;..\coreMQTT_Windows_Simulator\common\WinPCap;..\..\..\FreeRTOS\Source\include;..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\Source\corePKCS11\source\include;..\..\Source\corePKCS11\source\dependency\3rdparty\pkcs11;..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\Source\Utilities\backoff_algorithm\source\include;..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp;..\..\Source\Application-Protocols\network_transport\using_mbedtls_pkcs11;..\..\Source\Utilities\mbedtls_freertos;..\..\Source\mbedtls_utils;..\..\ThirdParty\mbedtls\include;.;..\..\Source\corePKCS11\source\portable\os;%(AdditionalIncludeDirectories) MBEDTLS_CONFIG_FILE="mbedtls_config.h";WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -168,7 +168,8 @@ - + + @@ -293,6 +294,7 @@ + diff --git a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj.filters index 3d0f40755..ee5f09497 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj.filters +++ b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/WIN32.vcxproj.filters @@ -152,9 +152,6 @@ FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11 - - FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11 - FreeRTOS+\mbedtls @@ -433,6 +430,10 @@ FreeRTOS+\FreeRTOS IoT Libraries\platform\transport + + + FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11 + @@ -840,6 +841,11 @@ FreeRTOS+\FreeRTOS IoT Libraries\platform\transport\include + + + + FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11\include + diff --git a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/pkcs11_demo_setup.py b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/pkcs11_demo_setup.py index f4925d80f..f8f84fd44 100755 --- a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/pkcs11_demo_setup.py +++ b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/pkcs11_demo_setup.py @@ -5,8 +5,8 @@ from cryptography import x509 from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization -KEY_OUT_NAME = "FreeRTOS_P11_Key.dat" -CERT_OUT_NAME = "FreeRTOS_P11_Certificate.dat" +KEY_OUT_NAME = "corePKCS11_Key.dat" +CERT_OUT_NAME = "corePKCS11_Certificate.dat" def convert_pem_to_der(cert_file, key_file): diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj index 4d9a460d1..4c9721e23 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj @@ -58,7 +58,7 @@ Disabled - ..\..\..\FreeRTOS-Plus\Source\Utilities\logging;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\dependency\3rdparty\pkcs11;..\..\ThirdParty\mbedtls\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\dependency\3rdparty\mbedtls_utils;..\..\..\FreeRTOS\Source\include;..\..\..\FreeRTOS\Source\portable\MSVC-MingW;examples;.;%(AdditionalIncludeDirectories) + ..\..\..\FreeRTOS-Plus\Source\Utilities\logging;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\dependency\3rdparty\pkcs11;..\..\ThirdParty\mbedtls\include;..\..\..\FreeRTOS-Plus\Source\corePKCS11\source\dependency\3rdparty\mbedtls_utils;..\..\..\FreeRTOS\Source\include;..\..\..\FreeRTOS\Source\portable\MSVC-MingW;examples;.;..\..\Source\corePKCS11\source\portable\os;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;MBEDTLS_CONFIG_FILE="aws_mbedtls_config.h";CONFIG_MEDTLS_USE_AFR_MEMORY;%(PreprocessorDefinitions) false EnableFastChecks @@ -241,7 +241,8 @@ - + + @@ -352,6 +353,7 @@ + diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj.filters index 22efa8d16..5dcd8806e 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj.filters +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/WIN32.vcxproj.filters @@ -359,15 +359,19 @@ FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11 - - FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11 - FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11 FreeRTOS+\FreeRTOS IoT Libraries\platform\mbedtls + + + FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11 + + + FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11 + @@ -712,5 +716,9 @@ Config + + + FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11\include + \ No newline at end of file diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/objects.c b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/objects.c index 2518c5e3c..0dce0b402 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/objects.c +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/examples/objects.c @@ -248,7 +248,7 @@ static void prvObjectImporting( void ) * Compare the hard coded x509, in PEM format, with the DER formatted * x509 certificate that is created by the Cryptoki library, with the following * OpenSSL command: - * "$ openssl x509 -in FreeRTOS_P11_Certificate.dat -inform der -text" + * "$ openssl x509 -in corePKCS11_Certificate.dat -inform der -text" * * See this explanation for the difference between the PEM format and the * DER format: @@ -263,7 +263,7 @@ static void prvObjectImporting( void ) configASSERT( xResult == CKR_OK ); configASSERT( xCertHandle != CK_INVALID_HANDLE ); - configPRINTF( ( "FreeRTOS_P11_Certificate.dat has been created in the Visual Studio" \ + configPRINTF( ( "corePKCS11_Certificate.dat has been created in the Visual Studio" \ " Solution directory\r\n" ) ); vPortFree( pucDerObject ); @@ -365,7 +365,7 @@ static void prvObjectGeneration( void ) pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS ) ); /* This function will generate a new EC private and public key pair. You can - * use " $openssl ec -inform der -in FreeRTOS_P11_Key.dat -text " to see + * use " $openssl ec -inform der -in corePKCS11_Key.dat -text " to see * the structure of the keys that were generated. */ xResult = pxFunctionList->C_GenerateKeyPair( hSession, @@ -377,7 +377,7 @@ static void prvObjectGeneration( void ) &xPublicKeyHandle, &xPrivateKeyHandle ); configASSERT( xResult == CKR_OK ); - configPRINTF( ( "FreeRTOS_P11_Key.dat has been created in the Visual Studio" \ + configPRINTF( ( "corePKCS11_Key.dat has been created in the Visual Studio" \ " Solution directory\r\n" ) ); configPRINTF( ( "Extracting public key bytes...\r\n" ) ); -- cgit v1.2.1