OpenPGP: update card capabilities from historical bytes
According to OpenPGP card specs 1.1 & 2.0 historical bytes in the ATR indicate capabilities: * bit 0x40 of the 3rd byte of the compact-TLV entry with TL 0x73 tells whether the card supports extended Lc/Le fields in APDUs. Signed-off-by: Peter Marschall <peter@adpm.de> git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5478 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
1bb69cb847
commit
1911db7532
|
@ -207,6 +207,21 @@ pgp_init(sc_card_t *card)
|
|||
return SC_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* update card capabilities from ATR */
|
||||
if (card->atr.len > 0) {
|
||||
unsigned char *hist_bytes = card->atr.value;
|
||||
size_t len = card->atr.len;
|
||||
size_t i = 0;
|
||||
|
||||
while ((i < len) && (hist_bytes[i] != 0x73))
|
||||
i++;
|
||||
|
||||
/* bit 0x40 in byte 3 of TL 0x73 means "extended Le/Lc" */
|
||||
if ((hist_bytes[i] == 0x73) && (len > i+3) &&
|
||||
(hist_bytes[i+3] & 0x40))
|
||||
card->caps |= SC_CARD_CAP_APDU_EXT;
|
||||
}
|
||||
|
||||
return SC_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue