@@ -44,14 +44,16 @@ static const char *TAG = "PKCS11";
44
44
#define pkcs11palFILE_NAME_CLIENT_CERTIFICATE "P11_Cert"
45
45
#define pkcs11palFILE_NAME_KEY "P11_Key"
46
46
#define pkcs11palFILE_CODE_SIGN_PUBLIC_KEY "P11_CSK"
47
+ #define pkcs11palFILE_JITP_CERTIFICATE "P11_JITP"
47
48
48
49
enum eObjectHandles
49
50
{
50
51
eInvalidHandle = 0 , /* According to PKCS #11 spec, 0 is never a valid object handle. */
51
52
eAwsDevicePrivateKey = 1 ,
52
53
eAwsDevicePublicKey ,
53
54
eAwsDeviceCertificate ,
54
- eAwsCodeSigningKey
55
+ eAwsCodeSigningKey ,
56
+ eAwsJITPCertificate
55
57
};
56
58
/*-----------------------------------------------------------*/
57
59
@@ -86,6 +88,7 @@ static void initialize_nvs_partition()
86
88
87
89
esp_err_t ret = nvs_flash_secure_init_partition (NVS_PART_NAME , & cfg );
88
90
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND ) {
91
+ ESP_LOGW (TAG , "Error initialising the NVS partition [%d]. Erasing the partition." , ret );
89
92
ESP_ERROR_CHECK (nvs_flash_erase_partition (NVS_PART_NAME ));
90
93
ret = nvs_flash_secure_init_partition (NVS_PART_NAME , & cfg );
91
94
}
@@ -94,6 +97,7 @@ static void initialize_nvs_partition()
94
97
#endif // CONFIG_NVS_ENCRYPTION
95
98
esp_err_t ret = nvs_flash_init_partition (NVS_PART_NAME );
96
99
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND ) {
100
+ ESP_LOGW (TAG , "Error initialising the NVS partition [%d]. Erasing the partition." , ret );
97
101
ESP_ERROR_CHECK (nvs_flash_erase_partition (NVS_PART_NAME ));
98
102
ret = nvs_flash_init_partition (NVS_PART_NAME );
99
103
}
@@ -143,6 +147,13 @@ void prvLabelToFilenameHandle( uint8_t * pcLabel,
143
147
* pcFileName = pkcs11palFILE_CODE_SIGN_PUBLIC_KEY ;
144
148
* pHandle = eAwsCodeSigningKey ;
145
149
}
150
+ else if ( 0 == memcmp ( pcLabel ,
151
+ pkcs11configLABEL_JITP_CERTIFICATE ,
152
+ strlen ( (char * )pkcs11configLABEL_JITP_CERTIFICATE ) ) )
153
+ {
154
+ * pcFileName = pkcs11palFILE_JITP_CERTIFICATE ;
155
+ * pHandle = eAwsJITPCertificate ;
156
+ }
146
157
else
147
158
{
148
159
* pcFileName = NULL ;
@@ -300,6 +311,11 @@ CK_RV PKCS11_PAL_GetObjectValue( CK_OBJECT_HANDLE xHandle,
300
311
pcFileName = pkcs11palFILE_CODE_SIGN_PUBLIC_KEY ;
301
312
* pIsPrivate = CK_FALSE ;
302
313
}
314
+ else if ( xHandle == eAwsJITPCertificate )
315
+ {
316
+ pcFileName = pkcs11palFILE_JITP_CERTIFICATE ;
317
+ * pIsPrivate = CK_FALSE ;
318
+ }
303
319
else
304
320
{
305
321
ulReturn = CKR_OBJECT_HANDLE_INVALID ;
0 commit comments