card-piv: store serial number into the 'serialnr' member of sc_card structure ...

... when serial number was asked for the first time.
Then return the stored value for the every next request of serial number.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5348 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
vtarasov 2011-04-16 17:35:56 +00:00
parent e2aac209d2
commit 28ccae7918
1 changed files with 6 additions and 1 deletions

View File

@ -1690,6 +1690,10 @@ static int piv_get_serial_nr_from_CHUI(sc_card_t* card, sc_serial_number_t* seri
size_t templen = sizeof(temp);
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
if (card->serialnr.len) {
*serial = card->serialnr;
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
}
/* ensure we've got the PIV selected, and nothing else is in process */
/* This fixes several problems due to previous incomplete APDUs during card detection */
@ -1737,7 +1741,8 @@ static int piv_get_serial_nr_from_CHUI(sc_card_t* card, sc_serial_number_t* seri
}
}
}
card->serialnr = *serial;
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
}