Hi @strofald
This is described in section "6.2.3 Key import" in HSE firmware reference manual v2.6. See Table 47 and Table 48. These tables show the difference when importing/updating empty slot and "non-empty" slot. If a slot is non-empty, authentication is mandatory, encryption is optional.
Authentication means that a container needs to be authenticated by Ka. In other words, you need to know another key (Ka) to be able to update your key. It is not simple operation and it is not supported by Crypto driver. Easiest options is to erase the key (you need to have super user rights) and then import the key again as usual.
Attached is SW example which shows how to erase the key. It's updated SW example from RTD, just this functionality was added.
Demo environment:
RTD: SW32K3_S32M27x_RTD_4.4_4.0.0_P20,
EB Tresos: 29.0.0
If you have SHE key, you need to follow memory update protocol described by SHE specification. That means you need to calculate new M1-M5 values with increased key counter and with knowledge of previous key or MASTER_ECU_KEY.
Regards,
Lukas