Update Fleet Provisioning WinSim Demo build files

This commit is contained in:
Paul Bartell
2022-11-01 18:18:08 -07:00
parent 77ca183eb5
commit df2b42f33d
5 changed files with 444 additions and 315 deletions

View File

@@ -81,7 +81,6 @@
#include "mqtt_pkcs11_demo_helpers.h"
#include "pkcs11_operations.h"
#include "tinycbor_serializer.h"
#include "using_mbedtls_pkcs11.h"
/**
* These configurations are required. Throw compilation error if it is not
@@ -520,12 +519,6 @@ static bool prvUnsubscribeFromRegisterThingResponseTopics( void )
*/
void vStartFleetProvisioningDemo()
{
/* Configure mbedTLS to use FreeRTOS specific threading function. */
mbedtls_threading_set_alt( mbedtls_platform_mutex_init,
mbedtls_platform_mutex_free,
mbedtls_platform_mutex_lock,
mbedtls_platform_mutex_unlock );
/* This example uses a single application task, which shows that how to use
* Fleet Provisioning library to generate and sign certificates with AWS IoT
* and create new IoT Things using the AWS IoT Fleet Provisioning API */

View File

@@ -1,25 +1,84 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31729.503
# Visual Studio Version 17
VisualStudioVersion = 17.3.32819.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RTOSDemo", "WIN32.vcxproj", "{C686325E-3261-42F7-AEB1-DDE5280E1CEB}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS-Kernel", "..\..\..\..\WindowsSimulator\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj", "{72C209C4-49A4-4942-A201-44706C9D77EC}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS+TCP", "..\..\..\..\WindowsSimulator\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj", "{C90E6CC5-818B-4C97-8876-0986D989387C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Fleet Provisioning Demo", "fleet_provisioning_demo.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logging", "..\..\..\..\WindowsSimulator\Logging\Logging.vcxproj", "{BE362AC0-B10B-4276-B84E-6304652BA228}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MbedTLS", "..\..\..\..\WindowsSimulator\MbedTLS\MbedTLS.vcxproj", "{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "corePKCS11", "..\..\..\..\WindowsSimulator\corePKCS11\corePKCS11.vcxproj", "{19F0FF1A-3368-491A-9932-A2F089508F51}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Debug|x86.ActiveCfg = Debug|Win32
{C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Debug|x86.Build.0 = Debug|Win32
{C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Release|x86.ActiveCfg = Release|Win32
{C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Release|x86.Build.0 = Release|Win32
{72C209C4-49A4-4942-A201-44706C9D77EC}.Debug|Win32.ActiveCfg = Debug|Win32
{72C209C4-49A4-4942-A201-44706C9D77EC}.Debug|Win32.Build.0 = Debug|Win32
{72C209C4-49A4-4942-A201-44706C9D77EC}.Debug|x64.ActiveCfg = Debug|x64
{72C209C4-49A4-4942-A201-44706C9D77EC}.Debug|x64.Build.0 = Debug|x64
{72C209C4-49A4-4942-A201-44706C9D77EC}.Release|Win32.ActiveCfg = Release|Win32
{72C209C4-49A4-4942-A201-44706C9D77EC}.Release|Win32.Build.0 = Release|Win32
{72C209C4-49A4-4942-A201-44706C9D77EC}.Release|x64.ActiveCfg = Release|x64
{72C209C4-49A4-4942-A201-44706C9D77EC}.Release|x64.Build.0 = Release|x64
{C90E6CC5-818B-4C97-8876-0986D989387C}.Debug|Win32.ActiveCfg = Debug|Win32
{C90E6CC5-818B-4C97-8876-0986D989387C}.Debug|Win32.Build.0 = Debug|Win32
{C90E6CC5-818B-4C97-8876-0986D989387C}.Debug|x64.ActiveCfg = Debug|x64
{C90E6CC5-818B-4C97-8876-0986D989387C}.Debug|x64.Build.0 = Debug|x64
{C90E6CC5-818B-4C97-8876-0986D989387C}.Release|Win32.ActiveCfg = Release|Win32
{C90E6CC5-818B-4C97-8876-0986D989387C}.Release|Win32.Build.0 = Release|Win32
{C90E6CC5-818B-4C97-8876-0986D989387C}.Release|x64.ActiveCfg = Release|x64
{C90E6CC5-818B-4C97-8876-0986D989387C}.Release|x64.Build.0 = Release|x64
{382DC80F-E278-4BC9-9DB6-59014486DA0F}.Debug|Win32.ActiveCfg = Debug|Win32
{382DC80F-E278-4BC9-9DB6-59014486DA0F}.Debug|Win32.Build.0 = Debug|Win32
{382DC80F-E278-4BC9-9DB6-59014486DA0F}.Debug|x64.ActiveCfg = Debug|x64
{382DC80F-E278-4BC9-9DB6-59014486DA0F}.Debug|x64.Build.0 = Debug|x64
{382DC80F-E278-4BC9-9DB6-59014486DA0F}.Release|Win32.ActiveCfg = Release|Win32
{382DC80F-E278-4BC9-9DB6-59014486DA0F}.Release|Win32.Build.0 = Release|Win32
{382DC80F-E278-4BC9-9DB6-59014486DA0F}.Release|x64.ActiveCfg = Release|x64
{382DC80F-E278-4BC9-9DB6-59014486DA0F}.Release|x64.Build.0 = Release|x64
{BE362AC0-B10B-4276-B84E-6304652BA228}.Debug|Win32.ActiveCfg = Debug|Win32
{BE362AC0-B10B-4276-B84E-6304652BA228}.Debug|Win32.Build.0 = Debug|Win32
{BE362AC0-B10B-4276-B84E-6304652BA228}.Debug|x64.ActiveCfg = Debug|x64
{BE362AC0-B10B-4276-B84E-6304652BA228}.Debug|x64.Build.0 = Debug|x64
{BE362AC0-B10B-4276-B84E-6304652BA228}.Release|Win32.ActiveCfg = Release|Win32
{BE362AC0-B10B-4276-B84E-6304652BA228}.Release|Win32.Build.0 = Release|Win32
{BE362AC0-B10B-4276-B84E-6304652BA228}.Release|x64.ActiveCfg = Release|x64
{BE362AC0-B10B-4276-B84E-6304652BA228}.Release|x64.Build.0 = Release|x64
{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}.Debug|Win32.ActiveCfg = Debug|Win32
{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}.Debug|Win32.Build.0 = Debug|Win32
{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}.Debug|x64.ActiveCfg = Debug|x64
{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}.Debug|x64.Build.0 = Debug|x64
{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}.Release|Win32.ActiveCfg = Release|Win32
{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}.Release|Win32.Build.0 = Release|Win32
{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}.Release|x64.ActiveCfg = Release|x64
{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}.Release|x64.Build.0 = Release|x64
{19F0FF1A-3368-491A-9932-A2F089508F51}.Debug|Win32.ActiveCfg = Debug|Win32
{19F0FF1A-3368-491A-9932-A2F089508F51}.Debug|Win32.Build.0 = Debug|Win32
{19F0FF1A-3368-491A-9932-A2F089508F51}.Debug|x64.ActiveCfg = Debug|x64
{19F0FF1A-3368-491A-9932-A2F089508F51}.Debug|x64.Build.0 = Debug|x64
{19F0FF1A-3368-491A-9932-A2F089508F51}.Release|Win32.ActiveCfg = Release|Win32
{19F0FF1A-3368-491A-9932-A2F089508F51}.Release|Win32.Build.0 = Release|Win32
{19F0FF1A-3368-491A-9932-A2F089508F51}.Release|x64.ActiveCfg = Release|x64
{19F0FF1A-3368-491A-9932-A2F089508F51}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {573E92F2-7674-4EE8-A7FD-8128A495333D}
SolutionGuid = {3876F3F5-8086-4F8E-BB5E-D8840E7D926C}
EndGlobalSection
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = FreeRTOS_Plus_TCP_Minimal.vsmdi
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,235 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{382dc80f-e278-4bc9-9db6-59014486da0f}</ProjectGuid>
<RootNamespace>corePKCS11_MQTT_Mutual_Auth</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>Fleet Provisioning Demo</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);.;..\..\..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp;..\..\..\..\Source\Application-Protocols\network_transport;..\..\..\..\Source\Utilities\backoff_algorithm\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\..\..\ThirdParty\tinycbor\src;..\..\..\..\Source\AWS\fleet-provisioning\source\include;..\..\Mqtt_Demo_Helpers;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);.;..\..\..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp;..\..\..\..\Source\Application-Protocols\network_transport;..\..\..\..\Source\Utilities\backoff_algorithm\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\..\..\ThirdParty\tinycbor\src;..\..\..\..\Source\AWS\fleet-provisioning\source\include;..\..\Mqtt_Demo_Helpers;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);.;..\..\..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp;..\..\..\..\Source\Application-Protocols\network_transport;..\..\..\..\Source\Utilities\backoff_algorithm\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\..\..\ThirdParty\tinycbor\src;..\..\..\..\Source\AWS\fleet-provisioning\source\include;..\..\Mqtt_Demo_Helpers;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);.;..\..\..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp;..\..\..\..\Source\Application-Protocols\network_transport;..\..\..\..\Source\Utilities\backoff_algorithm\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\include;..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface;..\..\..\..\ThirdParty\tinycbor\src;..\..\..\..\Source\AWS\fleet-provisioning\source\include;..\..\Mqtt_Demo_Helpers;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Label="Vcpkg">
<VcpkgEnabled>false</VcpkgEnabled>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>MBEDTLS_CONFIG_FILE="mbedtls_config_v3.2.1.h";_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>MBEDTLS_CONFIG_FILE="mbedtls_config_v3.2.1.h";_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>MBEDTLS_CONFIG_FILE="mbedtls_config_v3.2.1.h";_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>MBEDTLS_CONFIG_FILE="mbedtls_config_v3.2.1.h";_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_state.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_bio_freertos_plus_tcp.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_pk_pkcs11.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp\sockets_wrapper.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\transport_mbedtls_pkcs11.c" />
<ClCompile Include="..\..\..\..\Source\AWS\fleet-provisioning\source\fleet_provisioning.c" />
<ClCompile Include="..\..\..\..\Source\Utilities\backoff_algorithm\source\backoff_algorithm.c" />
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborencoder.c" />
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborencoder_close_container_checked.c" />
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborencoder_float.c" />
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborerrorstrings.c" />
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborparser.c" />
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborparser_dup_string.c" />
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborparser_float.c" />
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborvalidation.c" />
<ClCompile Include="..\..\Mqtt_Demo_Helpers\mqtt_pkcs11_demo_helpers.c" />
<ClCompile Include="FleetProvisioningDemoExample.c" />
<ClCompile Include="main.c" />
<ClCompile Include="pkcs11_operations.c" />
<ClCompile Include="tinycbor_serializer.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt.h" />
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_config_defaults.h" />
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_serializer.h" />
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_state.h" />
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface\transport_interface.h" />
<ClInclude Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_pk_pkcs11.h" />
<ClInclude Include="..\..\..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp\sockets_wrapper.h" />
<ClInclude Include="..\..\..\..\Source\Application-Protocols\network_transport\transport_mbedtls_pkcs11.h" />
<ClInclude Include="..\..\..\..\Source\AWS\fleet-provisioning\source\include\fleet_provisioning.h" />
<ClInclude Include="..\..\..\..\Source\AWS\fleet-provisioning\source\include\fleet_provisioning_config_defaults.h" />
<ClInclude Include="..\..\..\..\Source\Utilities\backoff_algorithm\source\include\backoff_algorithm.h" />
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\cbor.h" />
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\cborinternal_p.h" />
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\cborjson.h" />
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\compilersupport_p.h" />
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\tinycbor-version.h" />
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\utf8_p.h" />
<ClInclude Include="..\..\Mqtt_Demo_Helpers\mqtt_pkcs11_demo_helpers.h" />
<ClInclude Include="core_mqtt_config.h" />
<ClInclude Include="demo_config.h" />
<ClInclude Include="fleet_provisioning_config.h" />
<ClInclude Include="pkcs11_operations.h" />
<ClInclude Include="tinycbor_serializer.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\WindowsSimulator\corePKCS11\corePKCS11.vcxproj">
<Project>{19f0ff1a-3368-491a-9932-a2f089508f51}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\WindowsSimulator\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj">
<Project>{c90e6cc5-818b-4c97-8876-0986d989387c}</Project>
<Private>false</Private>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
<ProjectReference Include="..\..\..\..\WindowsSimulator\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj">
<Project>{72c209c4-49a4-4942-a201-44706c9d77ec}</Project>
<Private>false</Private>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
<ProjectReference Include="..\..\..\..\WindowsSimulator\Logging\Logging.vcxproj">
<Project>{be362ac0-b10b-4276-b84e-6304652ba228}</Project>
<Private>false</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\WindowsSimulator\MbedTLS\MbedTLS.vcxproj">
<Project>{e1016f3e-94e9-4864-9fd8-1d7c1fefbfd7}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="backoff_algorithm">
<UniqueIdentifier>{a442e1bd-e141-45a4-860d-a8eccab1b8c2}</UniqueIdentifier>
</Filter>
<Filter Include="network_transport">
<UniqueIdentifier>{ec612a95-3f21-4e0a-b9cd-0ba89d62067e}</UniqueIdentifier>
</Filter>
<Filter Include="coreMQTT">
<UniqueIdentifier>{c69eabd6-7eed-4959-9351-41b8c3b731b8}</UniqueIdentifier>
</Filter>
<Filter Include="coreMQTT\include">
<UniqueIdentifier>{64a78119-97f6-4252-b793-87cb6e7902d1}</UniqueIdentifier>
</Filter>
<Filter Include="tinycbor">
<UniqueIdentifier>{58f51daa-dd72-4e9c-939d-3113f97234ca}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp\sockets_wrapper.c">
<Filter>network_transport</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Utilities\backoff_algorithm\source\backoff_algorithm.c">
<Filter>backoff_algorithm</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_bio_freertos_plus_tcp.c">
<Filter>network_transport</Filter>
</ClCompile>
<ClCompile Include="main.c" />
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer.c">
<Filter>coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_state.c">
<Filter>coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt.c">
<Filter>coreMQTT</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\transport_mbedtls_pkcs11.c">
<Filter>network_transport</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_pk_pkcs11.c">
<Filter>network_transport</Filter>
</ClCompile>
<ClCompile Include="pkcs11_operations.c" />
<ClCompile Include="tinycbor_serializer.c" />
<ClCompile Include="FleetProvisioningDemoExample.c" />
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborvalidation.c">
<Filter>tinycbor</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborencoder.c">
<Filter>tinycbor</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborencoder_close_container_checked.c">
<Filter>tinycbor</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborencoder_float.c">
<Filter>tinycbor</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborerrorstrings.c">
<Filter>tinycbor</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborparser.c">
<Filter>tinycbor</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborparser_dup_string.c">
<Filter>tinycbor</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ThirdParty\tinycbor\src\cborparser_float.c">
<Filter>tinycbor</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\Source\AWS\fleet-provisioning\source\fleet_provisioning.c" />
<ClCompile Include="..\..\Mqtt_Demo_Helpers\mqtt_pkcs11_demo_helpers.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\Source\Application-Protocols\network_transport\sockets_wrapper\freertos_plus_tcp\sockets_wrapper.h">
<Filter>network_transport</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\Source\Utilities\backoff_algorithm\source\include\backoff_algorithm.h">
<Filter>backoff_algorithm</Filter>
</ClInclude>
<ClInclude Include="demo_config.h" />
<ClInclude Include="core_mqtt_config.h" />
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_config_defaults.h">
<Filter>coreMQTT\include</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_serializer.h">
<Filter>coreMQTT\include</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_state.h">
<Filter>coreMQTT\include</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt.h">
<Filter>coreMQTT\include</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\Source\Application-Protocols\coreMQTT\source\interface\transport_interface.h">
<Filter>coreMQTT\include</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\Source\Application-Protocols\network_transport\transport_mbedtls_pkcs11.h">
<Filter>network_transport</Filter>
</ClInclude>
<ClInclude Include="pkcs11_operations.h" />
<ClInclude Include="tinycbor_serializer.h" />
<ClInclude Include="fleet_provisioning_config.h" />
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\cbor.h">
<Filter>tinycbor</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\cborinternal_p.h">
<Filter>tinycbor</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\cborjson.h">
<Filter>tinycbor</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\compilersupport_p.h">
<Filter>tinycbor</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\tinycbor-version.h">
<Filter>tinycbor</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\ThirdParty\tinycbor\src\utf8_p.h">
<Filter>tinycbor</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\Source\Application-Protocols\network_transport\mbedtls_pk_pkcs11.h">
<Filter>network_transport</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\Source\AWS\fleet-provisioning\source\include\fleet_provisioning.h" />
<ClInclude Include="..\..\..\..\Source\AWS\fleet-provisioning\source\include\fleet_provisioning_config_defaults.h" />
<ClInclude Include="..\..\Mqtt_Demo_Helpers\mqtt_pkcs11_demo_helpers.h" />
</ItemGroup>
</Project>

View File

@@ -44,67 +44,16 @@
#include "core_pkcs11_config.h"
#include "core_pki_utils.h"
#include "mbedtls_utils.h"
#include "mbedtls_pk_pkcs11.h"
/* MbedTLS include. */
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/entropy.h"
#include "mbedtls/entropy_poll.h"
#include "mbedtls/error.h"
#include "mbedtls/oid.h"
#include "mbedtls/pk.h"
#include "mbedtls/pk_internal.h"
#include "mbedtls/sha256.h"
#include "mbedtls/x509_crt.h"
#include "mbedtls/x509_csr.h"
/**
* @brief Represents string to be logged when mbedTLS returned error
* does not contain a high-level code.
*/
static const char * pcNoHighLevelMbedTlsCodeStr = "<No-High-Level-Code>";
/**
* @brief Represents string to be logged when mbedTLS returned error
* does not contain a low-level code.
*/
static const char * pcNoLowLevelMbedTlsCodeStr = "<No-Low-Level-Code>";
/**
* @brief Utility for converting the high-level code in an mbedTLS error to
* string, if the code-contains a high-level code; otherwise, using a default
* string.
*/
#define mbedtlsHighLevelCodeOrDefault( mbedTlsCode ) \
( mbedtls_high_level_strerr( mbedTlsCode ) != NULL ) \
? mbedtls_high_level_strerr( mbedTlsCode ) \
: pcNoHighLevelMbedTlsCodeStr
/**
* @brief Utility for converting the level-level code in an mbedTLS error to
* string, if the code-contains a level-level code; otherwise, using a default
* string.
*/
#define mbedtlsLowLevelCodeOrDefault( mbedTlsCode ) \
( mbedtls_low_level_strerr( mbedTlsCode ) != NULL ) \
? mbedtls_low_level_strerr( mbedTlsCode ) \
: pcNoLowLevelMbedTlsCodeStr
/**
* @brief Struct containing parameters needed by the signing callback.
*/
typedef struct SigningCallbackContext
{
CK_SESSION_HANDLE p11Session;
CK_OBJECT_HANDLE p11PrivateKey;
} SigningCallbackContext_t;
/**
* @brief Parameters for the signing callback. This needs to be global as
* MbedTLS passes the key context to the signing function, so we cannot pass
* our own.
*/
static SigningCallbackContext_t xSigningContext = { 0 };
/*-----------------------------------------------------------*/
/**
@@ -120,51 +69,6 @@ static CK_RV prvDestroyProvidedObjects( CK_SESSION_HANDLE xSession,
CK_OBJECT_CLASS * pxClass,
CK_ULONG xCount );
/**
* @brief Read the specified ECDSA public key into the MbedTLS ECDSA context.
*
* @param[in] xP11Session The PKCS #11 session.
* @param[in] pxEcdsaContext The context in which to store the key.
* @param[in] xPublicKey The public key to read.
*/
static int prvExtractEcPublicKey( CK_SESSION_HANDLE xP11Session,
mbedtls_ecdsa_context * pxEcdsaContext,
CK_OBJECT_HANDLE xPublicKey );
/**
* @brief MbedTLS callback for signing using the provisioned private key. Used for
* signing the CSR.
*
* @param[in] pxContext Unused.
* @param[in] xMdAlg Unused.
* @param[in] pucHash Data to sign.
* @param[in] xHashLen Length of #pucHash.
* @param[out] pucSig The signature
* @param[out] pxSigLen The length of the signature.
* @param[in] pxRng Unused.
* @param[in] pxRngContext Unused.
*/
static int32_t prvPrivateKeySigningCallback( void * pxContext,
mbedtls_md_type_t xMdAlg,
const unsigned char * pucHash,
size_t xHashLen,
unsigned char * pucSig,
size_t * pxSigLen,
int ( * pxRng )( void *, unsigned char *, size_t ),
void * pxRngContext );
/**
* @brief MbedTLS random generation callback to generate random values with
* PKCS #11.
*
* @param[in] pxCtx Pointer to the PKCS #11 session handle.
* @param[out] pucRandom Buffer to write random data to.
* @param[in] xRandomLength Length of random data to write.
*/
static int prvRandomCallback( void * pxCtx,
unsigned char * pucRandom,
size_t xRandomLength );
/**
* @brief Generate a new ECDSA key pair using PKCS #11.
*
@@ -236,184 +140,6 @@ static CK_RV prvDestroyProvidedObjects( CK_SESSION_HANDLE xSession,
/*-----------------------------------------------------------*/
static int prvExtractEcPublicKey( CK_SESSION_HANDLE xP11Session,
mbedtls_ecdsa_context * pxEcdsaContext,
CK_OBJECT_HANDLE xPublicKey )
{
CK_ATTRIBUTE xEcTemplate = { 0 };
int xMbedtlsRet = -1;
CK_RV xPkcs11ret = CKR_OK;
CK_BYTE pxEcPoint[ 67 ] = { 0 };
CK_FUNCTION_LIST_PTR xP11FunctionList;
mbedtls_ecdsa_init( pxEcdsaContext );
mbedtls_ecp_group_init( &( pxEcdsaContext->grp ) );
xPkcs11ret = C_GetFunctionList( &xP11FunctionList );
if( xPkcs11ret != CKR_OK )
{
LogError( ( "Could not get a PKCS #11 function pointer." ) );
}
else
{
xEcTemplate.type = CKA_EC_POINT;
xEcTemplate.pValue = pxEcPoint;
xEcTemplate.ulValueLen = sizeof( pxEcPoint );
xPkcs11ret = xP11FunctionList->C_GetAttributeValue( xP11Session, xPublicKey, &xEcTemplate, 1 );
if( xPkcs11ret != CKR_OK )
{
LogError( ( "Failed to extract EC public key. Could not get attribute value. "
"C_GetAttributeValue failed with %lu.", xPkcs11ret ) );
}
}
if( xPkcs11ret == CKR_OK )
{
xMbedtlsRet = mbedtls_ecp_group_load( &( pxEcdsaContext->grp ), MBEDTLS_ECP_DP_SECP256R1 );
if( xMbedtlsRet != 0 )
{
LogError( ( "Failed creating an EC key. "
"mbedtls_ecp_group_load failed: MbedTLS"
"error = %s : %s.",
mbedtlsHighLevelCodeOrDefault( xMbedtlsRet ),
mbedtlsLowLevelCodeOrDefault( xMbedtlsRet ) ) );
xPkcs11ret = CKR_FUNCTION_FAILED;
}
else
{
xMbedtlsRet = mbedtls_ecp_point_read_binary( &( pxEcdsaContext->grp ), &( pxEcdsaContext->Q ), &pxEcPoint[ 2 ], xEcTemplate.ulValueLen - 2 );
if( xMbedtlsRet != 0 )
{
LogError( ( "Failed creating an EC key. "
"mbedtls_ecp_group_load failed: MbedTLS"
"error = %s : %s.",
mbedtlsHighLevelCodeOrDefault( xMbedtlsRet ),
mbedtlsLowLevelCodeOrDefault( xMbedtlsRet ) ) );
xPkcs11ret = CKR_FUNCTION_FAILED;
}
}
}
return xMbedtlsRet;
}
/*-----------------------------------------------------------*/
static int32_t prvPrivateKeySigningCallback( void * pxContext,
mbedtls_md_type_t xMdAlg,
const unsigned char * pucHash,
size_t xHashLen,
unsigned char * pucSig,
size_t * pxSigLen,
int ( * pxRng )( void *, unsigned char *, size_t ),
void * pxRngContext )
{
CK_RV xRet = CKR_OK;
int32_t usResult = 0;
CK_MECHANISM xMech = { 0 };
CK_BYTE pxToBeSigned[ 256 ];
CK_ULONG xToBeSignedLen = sizeof( pxToBeSigned );
CK_FUNCTION_LIST_PTR xFunctionList = NULL;
/* Unreferenced parameters. */
( void ) ( pxContext );
( void ) ( pxRng );
( void ) ( pxRngContext );
( void ) ( xMdAlg );
/* Sanity check buffer length. */
if( xHashLen > sizeof( pxToBeSigned ) )
{
xRet = CKR_ARGUMENTS_BAD;
}
xMech.mechanism = CKM_ECDSA;
memcpy( pxToBeSigned, pucHash, xHashLen );
xToBeSignedLen = xHashLen;
if( xRet == CKR_OK )
{
xRet = C_GetFunctionList( &xFunctionList );
}
if( xRet == CKR_OK )
{
xRet = xFunctionList->C_SignInit( xSigningContext.p11Session, &xMech,
xSigningContext.p11PrivateKey );
}
if( xRet == CKR_OK )
{
*pxSigLen = sizeof( pxToBeSigned );
xRet = xFunctionList->C_Sign( xSigningContext.p11Session, pxToBeSigned,
xToBeSignedLen, pucSig, ( CK_ULONG_PTR ) pxSigLen );
}
if( xRet == CKR_OK )
{
/* PKCS #11 for P256 returns a 64-byte signature with 32 bytes for R and 32
* bytes for S. This must be converted to an ASN.1 encoded array. */
if( *pxSigLen != pkcs11ECDSA_P256_SIGNATURE_LENGTH )
{
xRet = CKR_FUNCTION_FAILED;
LogError( ( "Failed to sign message using PKCS #11. Expected signature "
"length of %lu, but received %lu.",
( unsigned long ) pkcs11ECDSA_P256_SIGNATURE_LENGTH,
( unsigned long ) *pxSigLen ) );
}
if( xRet == CKR_OK )
{
PKI_pkcs11SignatureTombedTLSSignature( pucSig, pxSigLen );
}
}
if( xRet != CKR_OK )
{
LogError( ( "Failed to sign message using PKCS #11 with error code %lu.", xRet ) );
usResult = -1;
}
return usResult;
}
/*-----------------------------------------------------------*/
static int prvRandomCallback( void * pxCtx,
unsigned char * pucRandom,
size_t xRandomLength )
{
CK_SESSION_HANDLE * pxP11Session = ( CK_SESSION_HANDLE * ) pxCtx;
CK_RV xRes;
CK_FUNCTION_LIST_PTR xP11FunctionList;
xRes = C_GetFunctionList( &xP11FunctionList );
if( xRes != CKR_OK )
{
LogError( ( "Failed to generate a random number in RNG callback. Could not get a "
"PKCS #11 function pointer." ) );
}
else
{
xRes = xP11FunctionList->C_GenerateRandom( *pxP11Session, pucRandom, xRandomLength );
if( xRes != CKR_OK )
{
LogError( ( "Failed to generate a random number in RNG callback. "
"C_GenerateRandom failed with %lu.", ( unsigned long ) xRes ) );
}
}
return ( int ) xRes;
}
/*-----------------------------------------------------------*/
static CK_RV prvGenerateKeyPairEC( CK_SESSION_HANDLE xSession,
const char * pcPrivateKeyLabel,
const char * pcPublicKeyLabel,
@@ -488,7 +214,6 @@ bool xGenerateKeyAndCsr( CK_SESSION_HANDLE xP11Session,
CK_OBJECT_HANDLE xPubKeyHandle;
CK_RV xPkcs11Ret = CKR_OK;
mbedtls_pk_context xPrivKey;
mbedtls_pk_info_t xPrivKeyInfo;
mbedtls_ecdsa_context xEcdsaContext;
mbedtls_x509write_csr xReq;
int32_t ulMbedtlsRet = -1;
@@ -505,6 +230,11 @@ bool xGenerateKeyAndCsr( CK_SESSION_HANDLE xP11Session,
&xPrivKeyHandle,
&xPubKeyHandle );
if( xPkcs11Ret == CKR_OK )
{
xPkcs11Ret = xPKCS11_initMbedtlsPkContext( &xPrivKey, xP11Session, xPrivKeyHandle );
}
if( xPkcs11Ret == CKR_OK )
{
mbedtls_x509write_csr_init( &xReq );
@@ -524,35 +254,16 @@ bool xGenerateKeyAndCsr( CK_SESSION_HANDLE xP11Session,
if( ulMbedtlsRet == 0 )
{
mbedtls_pk_init( &xPrivKey );
}
if( ulMbedtlsRet == 0 )
{
ulMbedtlsRet = prvExtractEcPublicKey( xP11Session, &xEcdsaContext, xPubKeyHandle );
}
if( ulMbedtlsRet == 0 )
{
xSigningContext.p11Session = xP11Session;
xSigningContext.p11PrivateKey = xPrivKeyHandle;
memcpy( &xPrivKeyInfo, pxHeader, sizeof( mbedtls_pk_info_t ) );
xPrivKeyInfo.sign_func = prvPrivateKeySigningCallback;
xPrivKey.pk_info = &xPrivKeyInfo;
xPrivKey.pk_ctx = &xEcdsaContext;
mbedtls_x509write_csr_set_key( &xReq, &xPrivKey );
ulMbedtlsRet = mbedtls_x509write_csr_pem( &xReq, ( unsigned char * ) pcCsrBuffer,
xCsrBufferLength, &prvRandomCallback,
xCsrBufferLength, &lPKCS11RandomCallback,
&xP11Session );
}
mbedtls_x509write_csr_free( &xReq );
mbedtls_ecdsa_free( &xEcdsaContext );
mbedtls_ecp_group_free( &( xEcdsaContext.grp ) );
lPKCS11PkMbedtlsCloseSessionAndFree( &xPrivKey );
}
*pxOutCsrLength = strlen( pcCsrBuffer );