allow changing eID-PIN on reader's PIN pad

This commit is contained in:
Frank Morgner
2013-06-04 12:35:09 +02:00
parent 10920e0135
commit eef401af00

View File

@@ -1080,6 +1080,7 @@ npa_reset_retry_counter(sc_card_t *card, enum s_type pin_id,
int r;
if (ask_for_secret && (!new || !new_len)) {
if (!(SC_READER_CAP_PIN_PAD & card->reader->capabilities)) {
p = malloc(MAX_PIN_LEN+1);
if (!p) {
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Not enough memory for new PIN.\n");
@@ -1097,6 +1098,7 @@ npa_reset_retry_counter(sc_card_t *card, enum s_type pin_id,
return SC_ERROR_INVALID_PIN_LENGTH;
new = p;
}
}
memset(&apdu, 0, sizeof apdu);
apdu.ins = 0x2C;
@@ -1105,7 +1107,7 @@ npa_reset_retry_counter(sc_card_t *card, enum s_type pin_id,
apdu.datalen = new_len;
apdu.lc = apdu.datalen;
if (new_len) {
if (new_len || ask_for_secret) {
apdu.p1 = 0x02;
apdu.cse = SC_APDU_CASE_3_SHORT;
} else {
@@ -1113,6 +1115,19 @@ npa_reset_retry_counter(sc_card_t *card, enum s_type pin_id,
apdu.cse = SC_APDU_CASE_1;
}
if (ask_for_secret && !new_len) {
struct sc_pin_cmd_data data;
data.apdu = &apdu;
data.cmd = SC_PIN_CMD_CHANGE;
data.flags = SC_PIN_CMD_IMPLICIT_CHANGE;
data.pin2.encoding = SC_PIN_ENCODING_ASCII;
data.pin2.length_offset = 0;
data.pin2.offset = 5;
data.pin2.max_length = MAX_PIN_LEN;
data.pin2.min_length = MIN_PIN_LEN;
data.pin2.pad_length = 0;
r = card->reader->ops->perform_verify(card->reader, &data);
} else
r = sc_transmit_apdu(card, &apdu);
if (p) {