Fix key deletion.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2024-03-27 15:18:01 +01:00
parent c609050b3c
commit 42f9402f8b

View File

@@ -981,10 +981,12 @@ static int cmd_move_key() {
to = EF_PIV_KEY_RETIRED18;
}
file_t *efs, *efd;
if (!(efs = search_by_fid(from, NULL, SPECIFY_EF)) || !(efd = search_by_fid(to, NULL, SPECIFY_EF))) {
if (!(efs = search_by_fid(from, NULL, SPECIFY_EF)) || (!(efd = search_by_fid(to, NULL, SPECIFY_EF)) && to != 0xFF)) {
return SW_FILE_NOT_FOUND();
}
flash_write_data_to_file(efd, file_get_data(efs), file_get_size(efs));
if (to != 0xFF) {
flash_write_data_to_file(efd, file_get_data(efs), file_get_size(efs));
}
flash_clear_file(efs);
low_flash_available();
return SW_OK();