Fix when importing a dkek and it fails.

Now the dkek state is returned to the previous one.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2022-12-06 20:11:26 +01:00
parent 6a57e67629
commit 691aa3308c
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3

View file

@ -56,8 +56,11 @@ int cmd_key_domain() {
}
import_dkek_share(p2, apdu.data);
if (++current_dkeks >= dkeks) {
if (save_dkek_key(p2, NULL) != CCID_OK)
if (save_dkek_key(p2, NULL) != CCID_OK) {
/* On fail, it will return to previous dkek state. */
import_dkek_share(p2, apdu.data);
return SW_FILE_NOT_FOUND();
}
}
uint8_t t[MAX_KEY_DOMAINS*2];
memcpy(t, kdata, tf_kd_size);