Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
<ClCompile Include="examples\management_and_rng.c" />
<ClCompile Include="examples\objects.c" />
<ClCompile Include="examples\mechanisms_and_digests.c" />
<ClCompile Include="examples\sign_and_verify.c" />
<ClCompile Include="main.c" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@
<ClCompile Include="examples\demo_helpers.c">
<Filter>examples</Filter>
</ClCompile>
<ClCompile Include="examples\sign_and_verify.c">
<Filter>examples</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="FreeRTOSConfig.h" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
* Slot and Token Management Functions
* Session Management Functions
* Random Number Generation Functions
*
* For simplicity, this file will refer to these functions as Management Functions.
*
*/
void vPKCS11ManagementAndRNGDemo( void )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
/* RSA private key that has been generated off the device.
* This key will be used as an example for importing an object onto the device.
* This is useful when the device itself cannot create credentials.
*
* WARNING: This should never be done in production. This key is only hardcoded
* in this demo for demonstration purposes. It is a major security risk to add
* a private key as a constant, or in readable memory.
*/
#define pkcs11demo_RSA_PRIVATE_KEY \
"" \
Expand Down Expand Up @@ -126,7 +130,7 @@ void vPKCS11ObjectDemo( void )
configPRINTF( ( "\r\nFinished PKCS #11 Objects Demo.\r\n" ) );
}

static void prvObjectImporting()
static void prvObjectImporting( void )
{
configPRINTF( ( "---------Importing Objects---------\r\n" ) );
configPRINTF( ( "Importing RSA Private Key...\r\n" ) );
Expand Down Expand Up @@ -241,8 +245,6 @@ static void prvObjectImporting()

configPRINTF( ( "Creating private key with label: %s \r\n",
pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS ) );
configPRINTF( ( "FreeRTOS_P11_Key.dat has been created in the Visual Studio" \
" Solution directory\r\n" ) );

/* Once the Cryptoki library has finished importing the new RSA private key
* a CK_OBJECT_HANDLE is associated with it. The application can now use this
Expand All @@ -268,6 +270,9 @@ static void prvObjectImporting()
configASSERT( xResult == CKR_OK );
configASSERT( xPrivateKeyHandle != CK_INVALID_HANDLE );

configPRINTF( ( "FreeRTOS_P11_Key.dat has been created in the Visual Studio" \
" Solution directory\r\n" ) );

/* Clean up mbed TLS context that was used to parse the RSA key. */
mbedtls_pk_free( &xMbedPkContext );

Expand All @@ -276,7 +281,7 @@ static void prvObjectImporting()
configPRINTF( ( "---------Finished Importing Objects---------\r\n" ) );
}

static void prvObjectGeneration()
static void prvObjectGeneration( void )
{
configPRINTF( ( "---------Generating Objects---------\r\n" ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,15 @@ void vPKCS11MechanismsAndDigestDemo( void );
*/
void vPKCS11ObjectDemo( void );

/* Prototype for the PKCS #11 "Sign and Verify" demo. This demo covers how
* PKCS #11 can be used to sign a message, and verify the integrity of a message
* using private and public keys.
*
* This demo will also cover the "iot_pkcs11.h" functions, and how they can be
* used to make the PKCS #11 flow easier to use.
*
* Warning: This demo depends on the objects created in the objects demo.
*/
void vPKCS11SignVerifyDemo( void );

#endif /* _PKCS11_DEMOS_h_ */
Loading