Mistake on this page? Email us

Deleting items

Deleting a single item

The KCM API for deleting a single item is kcm_item_delete(). You need to provide:

  • Item name.
  • Item name size.
  • Item type.

Example of how to delete a single item

kcm_status_e kcm_status;
uint8_t test_data[] = {0x0, 0x1, 0x2};
char* test_name = "test_name";

// Store item
kcm_status = kcm_item_store((uint8_t*)test_name, strlen(test_name), KCM_CONFIG_ITEM, true,
                        test_data, sizeof(test_data), NULL);
if(kcm_status != KCM_STATUS_SUCCESS) {
    return 1;
}

// Delete stored item
kcm_status = kcm_item_delete((uint8_t*)test_name, strlen(test_name), KCM_CONFIG_ITEM);
if(kcm_status != KCM_STATUS_SUCCESS) {
    return 1;
}

Deleting a certificate chain

The KCM API for deleting a certificate chain is kcm_cert_chain_delete().

Example of how to delete a certificate chain

kcm_status_e kcm_status;
char chain_file_name[] = "test_cert_chain";
size_t kcm_chain_len = 3;
kcm_cert_chain_handle cert_chain_handle;

// create chain
kcm_status = kcm_cert_chain_create(&cert_chain_handle, (uint8_t*)chain_file_name, strlen(chain_file_name), kcm_chain_len, false);
if(kcm_status != KCM_STATUS_SUCCESS) {
    return 1;
}  

//add certificate to chain using kcm_cert_chain_add_next()

//close certificate chain
kcm_status = kcm_cert_chain_close(cert_chain_handle);
if(kcm_status != KCM_STATUS_SUCCESS) {
    return 1;
}  

//delete chain
kcm_status = kcm_cert_chain_delete((uint8_t*)chain_file_name, strlen(chain_file_name));
if(kcm_status != KCM_STATUS_SUCCESS) {
    return 1;
}