From 396cbc46cf5c19b9e011558505f16640b9fce8a3 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Thu, 25 Mar 2021 18:26:11 +0000 Subject: [PATCH] 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 --- src/libopensc/card-iasecc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libopensc/card-iasecc.c b/src/libopensc/card-iasecc.c index 38ccc75b..8c5d17e1 100644 --- a/src/libopensc/card-iasecc.c +++ b/src/libopensc/card-iasecc.c @@ -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); }