Fix keygen in slot 93.

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

View File

@@ -806,12 +806,12 @@ static int cmd_asym_keygen() {
if (!has_mgm) {
return SW_SECURITY_STATUS_NOT_SATISFIED();
}
if (key_ref == 0x93) {
key_ref = EF_PIV_KEY_RETIRED18;
}
if (key_ref != EF_PIV_KEY_AUTHENTICATION && key_ref != EF_PIV_KEY_SIGNATURE && key_ref != EF_PIV_KEY_KEYMGM && key_ref != EF_PIV_KEY_CARDAUTH && !(key_ref >= EF_PIV_KEY_RETIRED1 && key_ref <= EF_PIV_KEY_RETIRED20)) {
return SW_INCORRECT_P1P2();
}
if (key_ref == 0x93) {
key_ref = EF_PIV_KEY_RETIRED18;
}
asn1_ctx_t ctxi, aac = {0};
asn1_ctx_init(apdu.data, (uint16_t)apdu.nc, &ctxi);
if (!asn1_find_tag(&ctxi, 0xAC, &aac) || asn1_len(&aac) == 0) {
@@ -889,6 +889,9 @@ static int cmd_asym_keygen() {
}
else if (a80.data[0] == PIV_ALGO_X25519) {
}
else {
return SW_DATA_INVALID();
}
uint8_t def_pinpol = PINPOLICY_ONCE;
if (key_ref == EF_PIV_KEY_SIGNATURE) {
def_pinpol = PINPOLICY_ALWAYS;