|
11 | 11 | </t>6.2 [Compile and run the PKCS11 test application](#62-compile-and-run-the-pkcs11-test-application)<br> |
12 | 12 |
|
13 | 13 | ## 1. Introduction |
14 | | -[PKCS #11 ](https://en.wikipedia.org/wiki/PKCS_11) is a standardize API to allow application software to use, create, modify and delete cryptographic objects. corePKCS11 defines a subset of PKCS#11 APIs to build FreeRTOS demos. The following table lists the PKCS#11 API subset and the targeting FreeRTOS demos. |
15 | | - |
16 | | - |
17 | | -|PKCS#11 API |Category |Any |Provisioning demo |TLS |FreeRTOS+TCP |OTA | |
18 | | -|--- |--- |--- |--- |--- |--- |--- | |
19 | | -|C_Initialize |General Purpose Functions |O | | | | | |
20 | | -|C_Finalize |General Purpose Functions |O | | | | | |
21 | | -|C_GetFunctionList |General Purpose Functions |O | | | | | |
22 | | -|C_GetSlotList |Slot and token management functions |O | | | | | |
23 | | -|C_GetMechanismInfo |Slot and token management functions |O | | | | | |
24 | | -|C_InitToken |Slot and token management functions | |O | | | | |
25 | | -|C_GetTokenInfo |Slot and token management functions | |O | | | | |
26 | | -|C_OpenSession |Session management functions |O | | | | | |
27 | | -|C_CloseSession |Session management functions |O | | | | | |
28 | | -|C_Login |Session management functions |O | | | | | |
29 | | -|C_CreateObject |Object managements functions | |O | | | | |
30 | | -|C_DestroyObject |Object managements functions | |O | | | | |
31 | | -|C_GetAttributeValue |Object managements functions | | |O | |O | |
32 | | -|C_FindObjectsInit |Object managements functions | | |O | |O | |
33 | | -|C_FindObjects |Object managements functions | | |O | |O | |
34 | | -|C_FindObjectsFinal |Object managements functions | | |O | |O | |
35 | | -|C_DigestInit |Message digesting functions | | | |O |O | |
36 | | -|C_DigestUpdate |Message digesting functions | | | |O |O | |
37 | | -|C_DigestFinal |Message digesting functions | | | |O |O | |
38 | | -|C_SignInit |Signing and MACing functions | | |O | | | |
39 | | -|C_Sign |Signing and MACing functions | | |O | | | |
40 | | -|C_VerifyInit |Functions for verifying signatures and MACs | | | | |O | |
41 | | -|C_Verify |Functions for verifying signatures and MACs | | | | |O | |
42 | | -|C_GenerateKeyPair |Key management functions | |O | | | | |
43 | | -|C_GenerateRandom |Random number generation functions | | |O |O | | |
44 | | - |
45 | | -The PKCS11 tests help to verify the implementation of PKCS11 subset. The test directly exercises the PKCS11 implementation on the device under testing. User runs the PKCS11 test by running a test application. The test application is usually implemented by calling the provided PKCS11 test routine from the main function. By passing this test, the PKCS11 subset implementation is validated to run the targeting FreeRTOS demos. |
| 14 | +[PKCS #11 ](https://en.wikipedia.org/wiki/PKCS_11) is a standardize API to allow application software to use, create, modify and delete cryptographic objects. |
| 15 | +The benefit of PKCS11 is that it allows the app to take advantage of offload crypto while mitigating the threats of private key cloning and theft. |
| 16 | + |
| 17 | +FreeRTOS uses a subset of PKCS11 APIs to keep lean. Implementers are free to integrate more than our required subset of PKCS #11, but it is optional to do so. |
| 18 | + |
| 19 | +The PKCS #11 API functions required by FreeRTOS are described in the following table. |
| 20 | + |
| 21 | +FreeRTOS Library | Required PKCS #11 API Family |
| 22 | +----------------------- | ---------------------------- |
| 23 | +Any | Initialize, Finalize, Open/Close Session, GetSlotList, Login |
| 24 | +Provisioning Demo | GenerateKeyPair, CreateObject, DestroyObject, InitToken, GetTokenInfo |
| 25 | +TLS | Random, Sign, FindObject, GetAttributeValue |
| 26 | +FreeRTOS+TCP | Random, Digest |
| 27 | +OTA | Verify, Digest, FindObject, GetAttributeValue |
| 28 | + |
| 29 | +The PKCS11 test validates the PKCS11 subset implementation. The test directly exercises the PKCS11 implementation on the device under testing. User runs the PKCS11 test by running a test application. The test application is usually implemented by calling the provided PKCS11 test routine from the main function. By passing this test, the PKCS11 subset implementation is validated to support required PKCS11 functions by FreeRTOS. |
46 | 30 |
|
47 | 31 | ## 2. PKCS11 Test Configurations |
48 | 32 |
|
@@ -170,6 +154,30 @@ void yourMainFunction( void ) |
170 | 154 | ## 6. Run The PKCS11 Test |
171 | 155 | ### 6.1 Setup the provisioning mechanism and key function |
172 | 156 | Setup the provisioning mechanism and key function in **test_param_config.h** according to the device capability. |
| 157 | +The following is a sample test_param_config.h if corePKCS11 is used for the PKCS11 implementation. |
| 158 | +```C |
| 159 | +#include "core_pkcs11_config.h" |
| 160 | +
|
| 161 | +/* Setup key function. */ |
| 162 | +#define PKCS11_TEST_RSA_KEY_SUPPORT ( 1 ) |
| 163 | +#define PKCS11_TEST_EC_KEY_SUPPORT ( 1 ) |
| 164 | +
|
| 165 | +/* Setup provisioning method. */ |
| 166 | +#define PKCS11_TEST_IMPORT_PRIVATE_KEY_SUPPORT ( 1 ) |
| 167 | +#define PKCS11_TEST_GENERATE_KEYPAIR_SUPPORT ( 1 ) |
| 168 | +#define PKCS11_TEST_PREPROVISIONED_SUPPORT ( 0 ) |
| 169 | +
|
| 170 | +/* The device credential labels. */ |
| 171 | +#define PKCS11_TEST_LABEL_DEVICE_PRIVATE_KEY_FOR_TLS pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS |
| 172 | +#define PKCS11_TEST_LABEL_DEVICE_PUBLIC_KEY_FOR_TLS pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS |
| 173 | +#define PKCS11_TEST_LABEL_DEVICE_CERTIFICATE_FOR_TLS pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS |
| 174 | +
|
| 175 | +/* JITP credential labels. */ |
| 176 | +#define PKCS11_TEST_JITP_CODEVERIFY_ROOT_CERT_SUPPORTED pkcs11configJITP_CODEVERIFY_ROOT_CERT_SUPPORTED |
| 177 | +#define PKCS11_TEST_LABEL_CODE_VERIFICATION_KEY pkcs11configLABEL_CODE_VERIFICATION_KEY |
| 178 | +#define PKCS11_TEST_LABEL_JITP_CERTIFICATE pkcs11configLABEL_JITP_CERTIFICATE |
| 179 | +#define PKCS11_TEST_LABEL_ROOT_CERTIFICATE pkcs11configLABEL_ROOT_CERTIFICATE |
| 180 | +``` |
173 | 181 |
|
174 | 182 | ### 6.2 Compile and run the PKCS11 test application |
175 | 183 | Compile and run the test application in your development environment. |
|
0 commit comments