libopensc: make sc_reset() take an additional parameter "do_cold_reset" which will unpower the card.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4896 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
martin 2010-11-30 11:22:31 +00:00
parent 5d9c02b197
commit 7ab591a684
4 changed files with 9 additions and 8 deletions

View File

@ -300,7 +300,7 @@ static int mcrd_init(sc_card_t * card)
/* Reset the MULTOS card to get to a known state */
if (card->type == SC_CARD_TYPE_MCRD_ESTEID_V11)
sc_reset(card);
sc_reset(card, 0);
/* Select the EstEID AID to get to a known state.
* For some reason a reset is required as well... */
@ -308,7 +308,7 @@ static int mcrd_init(sc_card_t * card)
flags = SC_ALGORITHM_RSA_HASH_SHA1 | SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_SHA256;
/* EstEID v3.0 supports 2048 bit keys */
_sc_card_add_rsa_alg(card, 2048, flags, 0);
sc_reset(card);
sc_reset(card, 0);
sc_format_apdu(card, &apdu, SC_APDU_CASE_3, 0xA4, 0x04, 0x00);
apdu.lc = sizeof(EstEID_v3_AID);

View File

@ -261,7 +261,7 @@ int sc_disconnect_card(sc_card_t *card)
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, 0);
}
int sc_reset(sc_card_t *card)
int sc_reset(sc_card_t *card, int do_cold_reset)
{
int r, r2;
@ -274,7 +274,7 @@ int sc_reset(sc_card_t *card)
if (r != SC_SUCCESS)
return r;
r = card->reader->ops->reset(card->reader);
r = card->reader->ops->reset(card->reader, do_cold_reset);
/* invalidate cache */
memset(&card->cache, 0, sizeof(card->cache));
card->cache_valid = 0;

View File

@ -311,7 +311,7 @@ struct sc_reader_operations {
int (*wait_for_event)(struct sc_context *ctx, unsigned int event_mask, sc_reader_t **event_reader, unsigned int *event,
int timeout, void **reader_states);
/* Reset a reader */
int (*reset)(struct sc_reader *);
int (*reset)(struct sc_reader *, int);
};
/*
@ -733,9 +733,10 @@ int sc_wait_for_event(sc_context_t *ctx, unsigned int event_mask,
* Resets the card.
* NOTE: only PC/SC backend implements this function at this moment.
* @param card The card to reset.
* @param do_cold_reset 0 for a warm reset, 1 for a cold reset (unpower)
* @retval SC_SUCCESS on success
*/
int sc_reset(sc_card_t *card);
int sc_reset(sc_card_t *card, int do_cold_reset);
/**
* Cancel all pending PC/SC calls

View File

@ -557,13 +557,13 @@ static int pcsc_release(sc_reader_t *reader)
return SC_SUCCESS;
}
static int pcsc_reset(sc_reader_t *reader)
static int pcsc_reset(sc_reader_t *reader, int do_cold_reset)
{
struct pcsc_private_data *priv = GET_PRIV_DATA(reader);
int r;
int old_locked = priv->locked;
r = pcsc_reconnect(reader, SCARD_UNPOWER_CARD);
r = pcsc_reconnect(reader, do_cold_reset ? SCARD_UNPOWER_CARD : SCARD_RESET_CARD);
if(r != SC_SUCCESS)
return r;