Andreas Jellinghaus wrote:
or mask both values before comparing?
ok
Index: card.c
===================================================================
--- card.c (revision 3093)
+++ card.c (working copy)
@@ -765,14 +765,20 @@
matr_len = strlen(matr);
if (tatr_len != matr_len)
continue;
+ tbin_len = sizeof(tbin);
+ sc_hex_to_bin(tatr, tbin, &tbin_len);
mbin_len = sizeof(mbin);
sc_hex_to_bin(matr, mbin, &mbin_len);
- if (mbin_len != card_atr_bin_len)
+ if (mbin_len != card_atr_bin_len) {
+ sc_error("length of atr and atr mask do
not match - ignored: %s - %s", tatr, matr);
continue;
should we really continue here ? After all it's an error in the
card driver.
+ }
+ /* reduce tatr with mask */
+ for (s = 0; s < tbin_len; s++)
+ tbin[s] = (tbin[s] & mbin[s]);
+ /* create copy of card_atr_bin masked) */
for (s = 0; s < mbin_len; s++)
mbin[s] = (card_atr_bin[s] & mbin[s]);
why not use one loop ? I think one loop is easier to read as it
clearly shows that the same mask is equally applied to both ATRs.
- tbin_len = sizeof(tbin);
- sc_hex_to_bin(tatr, tbin, &tbin_len);
if (memcmp(tbin, mbin, tbin_len) != 0)
continue;
} else {
might be easier to understand. also adds an error message for the
matr_len != tatr_len case which should not be silently ignored I think,
as a simply typo can trigger it.
Cheers,
Nils
_______________________________________________
opensc-devel mailing list
[email protected]
http://www.opensc-project.org/mailman/listinfo/opensc-devel