Skip to content

Commit

Permalink
Fix find for EC algos returning wrong algo
Browse files Browse the repository at this point in the history
If we're finding EC algo, and curve is not matched, another algo
with the same key length shoud not be returned.
  • Loading branch information
ya-isakov authored and Jakuje committed Dec 4, 2021
1 parent 9ac9295 commit bf4a3aa
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/libopensc/card.c
Original file line number Diff line number Diff line change
Expand Up @@ -1154,16 +1154,13 @@ sc_algorithm_info_t * sc_card_find_alg(sc_card_t *card,

if (info->algorithm != algorithm)
continue;
if (param) {
if (info->algorithm == SC_ALGORITHM_EC ||
info->algorithm == SC_ALGORITHM_EDDSA ||
info->algorithm == SC_ALGORITHM_XEDDSA)
if (sc_compare_oid((struct sc_object_id *)param, &info->u._ec.params.id))
return info;
}
if (info->key_length != key_length)
continue;
return info;
if (param && (info->algorithm == SC_ALGORITHM_EC ||
info->algorithm == SC_ALGORITHM_EDDSA ||
info->algorithm == SC_ALGORITHM_XEDDSA)) {
if (sc_compare_oid((struct sc_object_id *)param, &info->u._ec.params.id))
return info;
} else if (info->key_length == key_length)
return info;
}
return NULL;
}
Expand Down

0 comments on commit bf4a3aa

Please sign in to comment.