aboutsummaryrefslogtreecommitdiffstats
path: root/fingerpass.py
diff options
context:
space:
mode:
authorhploetz <hploetz@f711b948-2313-0410-aaa9-d29f33439f0b>2007-06-01 20:42:45 +0000
committerhploetz <hploetz@f711b948-2313-0410-aaa9-d29f33439f0b>2007-06-01 20:42:45 +0000
commit85335da1b6a7e208ebeab41ded2b3b27e9d19d51 (patch)
treea182f2e4fa9b67ebd2c4a88223eb9ba3ef5f9df0 /fingerpass.py
parent7819b38ec25650dba03d09f5aeaeed33ac2880f8 (diff)
Implement comments for fingerprints.txt
Add start of an implementation of rfid characteristics Update fingerprints after encounter with two real german passports git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@206 f711b948-2313-0410-aaa9-d29f33439f0b
Diffstat (limited to 'fingerpass.py')
-rwxr-xr-xfingerpass.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/fingerpass.py b/fingerpass.py
index dce8a83..e95534f 100755
--- a/fingerpass.py
+++ b/fingerpass.py
@@ -63,6 +63,16 @@ def connect(reader = None):
print "ATR: %s" % utils.hexdump(newState[0]['Atr'], short = True)
return pycsc.pycsc(reader = readerName, protocol = pycsc.SCARD_PROTOCOL_ANY)
+def fingerprint_rfid(card):
+ # Need RFID
+ if not isinstance(card, cards.rfid_card.RFID_Card):
+ return [""]
+
+ uid = card.get_uid()
+
+ return "%02X" % ord(uid[0])
+ # FIXME: Determine ISO type and then return a value depending on A-fixed UID vs. A-random UID vs. B
+
def fingerprint_7816(card):
# Need ISO 7816-4
if not isinstance(card, cards.iso_7816_4_card.ISO_7816_4_Card):
@@ -190,6 +200,7 @@ def fingerprint(card):
catr = "F:%s" % binascii.b2a_hex(atr)
result.append( catr )
result.extend( fingerprint_7816(card) )
+ result.append( fingerprint_rfid(card) )
return ",".join(result)
@@ -202,9 +213,12 @@ def match_fingerprint(fingerprint, database="fingerprints.txt"):
matched = False
def do_match(line, fingerprint):
- return re.match(line.strip()+"$", fingerprint.strip()) is not None
+ return re.match(line.strip(), fingerprint.strip()) is not None
for line in fp.readlines():
+ if line[0] == "#":
+ continue
+
if line.strip() == "":
matched = False
if len(current_result) > 0:
@@ -245,7 +259,9 @@ if __name__ == "__main__":
cards.generic_card.DEBUG = False
print >>sys.stderr, "Using %s" % card.DRIVER_NAME
-
+
+ if isinstance(card, cards.rfid_card.RFID_Card):
+ print "UID: %s" % utils.hexdump(card.get_uid(), short=True)
fp = fingerprint(card)
print "Fingerprint: %s" % fp
matches = match_fingerprint(fp)