Heiko Knospe wrote:
Hello,
my (actually fully supported) Cryptoflex 32K v4 card is not detected
because of a bug with ATR masking:
card.c:188:sc_connect_card: trying driver: flex
card.c:746:match_atr_table: ATR : 3b:95:18:40:ff:64:02:01:01:02
card.c:754:match_atr_table: ATR try : 3b:95:15:40:20:68:01:02:00:00
card.c:754:match_atr_table: ATR try : 3B:95:15:40:FF:68:01:02:02:01
card.c:754:match_atr_table: ATR try : 3B:95:15:40:FF:68:01:02:02:04
card.c:754:match_atr_table: ATR try : 3B:85:40:20:68:01:01:05:01
card.c:754:match_atr_table: ATR try : 3B:95:94:40:FF:63:01:01:02:01
card.c:754:match_atr_table: ATR try : 3B:95:15:40:FF:63:01:01:02:01
card.c:763:match_atr_table: ATR mask: FF:FF:FF:FF:FF:FF:FF:FF:00:00
card.c:754:match_atr_table: ATR try :
3B:95:18:40:FF:64:02:01:01:02 <---
card.c:763:match_atr_table: ATR mask: FF:FF:FF:FF:FF:FF:FF:FF:00:00
card.c:754:match_atr_table: ATR try : 3B:95:18:40:FF:62:01:01:00:00
....
The respective ATR bits have to be set to 0 (or card.c around line 776
would have to be modified).
what about the attached patch (untested) ? I think it would be
cleaner to compare only those bits specified in the mask.
Cheers,
Nils
Index: src/libopensc/card.c
===================================================================
--- src/libopensc/card.c (Revision 3103)
+++ src/libopensc/card.c (Arbeitskopie)
@@ -769,12 +769,12 @@
sc_hex_to_bin(matr, mbin, &mbin_len);
if (mbin_len != card_atr_bin_len)
continue;
- for (s = 0; s < mbin_len; s++)
- mbin[s] = (card_atr_bin[s] & mbin[s]);
tbin_len = sizeof(tbin);
sc_hex_to_bin(tatr, tbin, &tbin_len);
- if (memcmp(tbin, mbin, tbin_len) != 0)
- continue;
+ for (s = 0; s < mbin_len; s++)
+ if ((card_atr_bin[s] & mbin[s]) !=
+ (tbin[s] & mbin[s]))
+ continue;
} else {
if (strncasecmp(tatr, card_atr_hex, tatr_len) != 0)
continue;
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel