IASECC/CPX: set default flags

The CPX has the standard capabilities of the IASECC standard.

Let's be carefull with memory leakage, see the
previous commit 83162c5c8

Fix: issue #2270
This commit is contained in:
Vincent JARDIN 2021-03-25 18:26:11 +00:00 committed by Frank Morgner
parent 4912f05701
commit 396cbc46cf
1 changed files with 9 additions and 7 deletions

View File

@ -630,22 +630,24 @@ static int
iasecc_init_cpx(struct sc_card *card)
{
struct sc_context *ctx = card->ctx;
unsigned int flags; /* TBC it is not IASECC_CARD_DEFAULT_FLAGS */
unsigned int flags;
int rv = 0;
LOG_FUNC_CALLED(ctx);
card->caps = SC_CARD_CAP_RNG; /* TBC it is not IASECC_CARD_DEFAULT_CAPS */
card->caps = IASECC_CARD_DEFAULT_CAPS;
flags = SC_ALGORITHM_RSA_PAD_PKCS1;
flags |= SC_ALGORITHM_RSA_RAW;
flags |= SC_ALGORITHM_RSA_HASH_SHA1 |
SC_ALGORITHM_RSA_HASH_SHA256;
flags = IASECC_CARD_DEFAULT_FLAGS;
_sc_card_add_rsa_alg(card, 512, flags, 0);
_sc_card_add_rsa_alg(card, 1024, flags, 0);
_sc_card_add_rsa_alg(card, 2048, flags, 0);
rv = iasecc_parse_ef_atr(card);
if (rv)
sc_invalidate_cache(card); /* avoid memory leakage */
LOG_TEST_RET(ctx, rv, "Parse EF.ATR");
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
}