diff options
author | johnrhen <90864038+johnrhen@users.noreply.github.com> | 2021-11-23 16:21:52 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 16:21:52 -0800 |
commit | f04e39d641109eb6bc28f7f75cc8522011600d48 (patch) | |
tree | d2d48bad20572aae34510e31dad2896bdce97608 | |
parent | 74e03ddcfedecc4a1edd47a5e1fc549859405a50 (diff) | |
download | freertos-git-f04e39d641109eb6bc28f7f75cc8522011600d48.tar.gz |
PKCS11 Demo Failure Fixes (#720)
* 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>
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 fd238cbc8..d7340ba29 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 @@ </Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
- <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\using_mbedtls_pkcs11;..\..\Source\Utilities\mbedtls_freertos;..\..\Source\mbedtls_utils;..\..\ThirdParty\mbedtls\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <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\using_mbedtls_pkcs11;..\..\Source\Utilities\mbedtls_freertos;..\..\Source\mbedtls_utils;..\..\ThirdParty\mbedtls\include;.;..\..\Source\corePKCS11\source\portable\os;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>MBEDTLS_CONFIG_FILE="mbedtls_config.h";WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -168,7 +168,8 @@ <ClCompile Include="..\..\Source\corePKCS11\source\core_pkcs11.c" />
<ClCompile Include="..\..\Source\corePKCS11\source\core_pki_utils.c" />
<ClCompile Include="..\..\Source\corePKCS11\source\portable\mbedtls\core_pkcs11_mbedtls.c" />
- <ClCompile Include="..\..\Source\corePKCS11\source\portable\windows\core_pkcs11_pal.c" />
+ <ClCompile Include="..\..\Source\corePKCS11\source\portable\os\core_pkcs11_pal_utils.c" />
+ <ClCompile Include="..\..\Source\corePKCS11\source\portable\os\freertos_winsim\core_pkcs11_pal.c" />
<ClCompile Include="..\..\Source\Utilities\mbedtls_freertos\mbedtls_bio_freertos_plus_tcp.c" />
<ClCompile Include="..\..\Source\Utilities\mbedtls_freertos\mbedtls_freertos_port.c" />
<ClCompile Include="..\..\ThirdParty\mbedtls\library\aes.c" />
@@ -293,6 +294,7 @@ <ClInclude Include="..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp\sockets_wrapper.h" />
<ClInclude Include="..\..\Source\Application-Protocols\network_transport\using_mbedtls\using_mbedtls_pkcs11\using_mbedtls_pkcs11.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\include\core_pkcs11.h" />
+ <ClInclude Include="..\..\Source\corePKCS11\source\portable\os\core_pkcs11_pal_utils.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\include\core_pkcs11_pal.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\include\core_pki_utils.h" />
<ClInclude Include="..\..\Source\FreeRTOS-Plus-TCP\include\FreeRTOS_errno_TCP.h" />
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 38b7f8150..7cce74f22 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 @@ <ClCompile Include="..\..\Source\corePKCS11\source\portable\mbedtls\core_pkcs11_mbedtls.c">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11</Filter>
</ClCompile>
- <ClCompile Include="..\..\Source\corePKCS11\source\portable\windows\core_pkcs11_pal.c">
- <Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11</Filter>
- </ClCompile>
<ClCompile Include="..\..\ThirdParty\mbedtls\library\aes.c">
<Filter>FreeRTOS+\mbedtls</Filter>
</ClCompile>
@@ -433,6 +430,10 @@ <ClCompile Include="..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp\sockets_wrapper.c">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\platform\transport</Filter>
</ClCompile>
+ <ClCompile Include="..\..\Source\corePKCS11\source\portable\os\freertos_winsim\core_pkcs11_pal.c" />
+ <ClCompile Include="..\..\Source\corePKCS11\source\portable\os\core_pkcs11_pal_utils.c">
+ <Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\include\NetworkInterface.h">
@@ -839,6 +840,11 @@ <ClInclude Include="..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp\sockets_wrapper.h">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\platform\transport\include</Filter>
</ClInclude>
+ <ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\error.h" />
+ <ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\error.h" />
+ <ClInclude Include="..\..\Source\corePKCS11\source\portable\os\core_pkcs11_pal_utils.h">
+ <Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11\include</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="..\..\ThirdParty\mbedtls\library\CMakeLists.txt">
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 @@ </Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
- <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;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <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)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>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)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -241,7 +241,8 @@ <ClCompile Include="..\..\Source\corePKCS11\source\core_pkcs11.c" />
<ClCompile Include="..\..\Source\corePKCS11\source\core_pki_utils.c" />
<ClCompile Include="..\..\Source\corePKCS11\source\portable\mbedtls\core_pkcs11_mbedtls.c" />
- <ClCompile Include="..\..\Source\corePKCS11\source\portable\windows\core_pkcs11_pal.c" />
+ <ClCompile Include="..\..\Source\corePKCS11\source\portable\os\core_pkcs11_pal_utils.c" />
+ <ClCompile Include="..\..\Source\corePKCS11\source\portable\os\freertos_winsim\core_pkcs11_pal.c" />
<ClCompile Include="examples\demo_helpers.c" />
<ClCompile Include="examples\management_and_rng.c" />
<ClCompile Include="examples\objects.c" />
@@ -352,6 +353,7 @@ <ClInclude Include="..\..\Source\corePKCS11\source\dependency\3rdparty\pkcs11\pkcs11f.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\dependency\3rdparty\pkcs11\pkcs11t.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\include\core_pkcs11.h" />
+ <ClInclude Include="..\..\Source\corePKCS11\source\portable\os\core_pkcs11_pal_utils.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\include\core_pkcs11_pal.h" />
<ClInclude Include="..\..\Source\corePKCS11\source\include\core_pki_utils.h" />
<ClInclude Include="core_pkcs11_config.h" />
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 @@ <ClCompile Include="..\..\Source\corePKCS11\source\portable\mbedtls\core_pkcs11_mbedtls.c">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11</Filter>
</ClCompile>
- <ClCompile Include="..\..\Source\corePKCS11\source\portable\windows\core_pkcs11_pal.c">
- <Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11</Filter>
- </ClCompile>
<ClCompile Include="..\..\Source\corePKCS11\source\core_pki_utils.c">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\corePKCS11\source\dependency\3rdparty\mbedtls_utils\mbedtls_utils.c">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\platform\mbedtls</Filter>
</ClCompile>
+ <ClCompile Include="..\..\ThirdParty\mbedtls\library\error.c" />
+ <ClCompile Include="..\..\Source\corePKCS11\source\portable\os\core_pkcs11_pal_utils.c">
+ <Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\Source\corePKCS11\source\portable\os\freertos_winsim\core_pkcs11_pal.c">
+ <Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\FreeRTOS\Source\include\event_groups.h">
@@ -712,5 +716,9 @@ <ClInclude Include="core_pkcs11_config.h">
<Filter>Config</Filter>
</ClInclude>
+ <ClInclude Include="..\..\ThirdParty\mbedtls\include\mbedtls\error.h" />
+ <ClInclude Include="..\..\Source\corePKCS11\source\portable\os\core_pkcs11_pal_utils.h">
+ <Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\corePKCS11\include</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ 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" ) ); |