Skip to content

Commit

Permalink
dtrust: read serial number from EF.GDO
Browse files Browse the repository at this point in the history
This is necessary, because for D-Trust Cards 5.x the CardOS command
requires PACE authentication.
  • Loading branch information
hamarituc committed May 8, 2024
1 parent 1fb5655 commit 521e50c
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/libopensc/card-dtrust.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,14 @@ static int
_dtrust_get_serialnr(sc_card_t *card)
{
int r;
u8 buf[32];

r = sc_get_data(card, 0x0181, buf, 32);
LOG_TEST_RET(card->ctx, r, "querying serial number failed");

if (r != 8) {
sc_log(card->ctx, "unexpected response to GET DATA serial number");
return SC_ERROR_INTERNAL;
card->serialnr.len = SC_MAX_SERIALNR;
r = sc_parse_ef_gdo(card, card->serialnr.value, &card->serialnr.len, NULL, 0);
if (r < 0) {
card->serialnr.len = 0;
return r;
}

/* cache serial number */
memcpy(card->serialnr.value, buf, 8);
card->serialnr.len = 8;

return SC_SUCCESS;
}

Expand Down

0 comments on commit 521e50c

Please sign in to comment.