Git Product home page Git Product logo

python-emv's Introduction

EMV for Python

Tests

A Pythonic implementation of the EMV smartcard protocol, which is used worldwide for chip-and-PIN payments. This is intended to be readable, tested, and heavily cross-referenced with the appropriate sections of the EMV Specification.

This also includes an implementation of the EMV CAP (aka Pinsentry) standard which is known to work for Barclays cards.

Installation

You'll need the pcsc smartcard libraries on your system in order to build the smartcard bindings. On Ubuntu:

sudo apt-get install build-essential swig libpcsclite-dev python-pip python-devel

Then you can install emv from pip:

sudo pip install emv

To check if everything's working, plug in a smartcard reader, put a bank card in, and run:

emvtool info

If all goes well, you should see some data about your card.

Warning

Although this tool has been relatively well tested, it's technically possible to block or even damage your card, as well as get in trouble with your card issuer, using this tool. Please make sure you understand the risks.

Commands marked in the --help output with [!] will initiate a transaction on the card, resulting in a permanent change to the card's internal state which could potentially be detected by your card issuer, particularly if you initiate many transactions.

Command Line

This library ships with emvtool - a simple command-line tool for testing and CAP password generation. To fetch some card metadata, run:

emvtool info

If you have more than one smartcard reader (or smartcard-like devices, such as a YubiKey) connected, you may have to select a specific reader. List all the readers with:

emvtool readers

Then use the -r option to select the specific reader ID, e.g.:

emvtool -r 1 info

To generate an EMV CAP one-time passcode:

emvtool -p <PIN> cap

You can also conduct CAP signing and challenge-response:

emvtool -p <PIN> cap -c <challenge>
emvtool -p <PIN> cap -c <accountno> -a <amount>

Legal Stuff

EMV is a trademark of EMVCo and is used purely for descriptive purposes. This library is not affiliated with EMVCo.

python-emv's People

Contributors

fabaff avatar idnorton avatar lukegb avatar martin3000 avatar nomis avatar przemobe avatar russss avatar tombull avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-emv's Issues

Apps are stored on some cards differently to how Barclays stores apps

For some cards (I've tested one like this from the Co-Operative Bank), the different apps are stored in different records rather than all in the one value. To get an accurate list of apps on a Co-Op card, you need to do something like:

def list_applications(self):
    res = self.tp.exchange(SelectCommand('1PAY.SYS.DDF01'))
    sfi = res.data[Tag.FCI][Tag.FCI_PROP][Tag.SFI][0]
    apps = []
    for i in range(1, 31):
        try:
            res = self.tp.exchange(ReadCommand(i, sfi))
        except:
            break
        new_apps = res.data[Tag.RECORD][Tag.APP]
        if type(new_apps) is not list:
            new_apps = [new_apps]
        apps.extend(new_apps)
    return apps

This isn't written well or with comments, which is why I've not submitted a pull request.

Error when read card

Hello Sir,
when i tried get data of card, it alwayls show this error for any command of emvtool
Can u check and help me fix it?

Thanks
emvtool -l debug info
INFO:emv.transmission:Connected to reader
DEBUG:emv.transmission:Tx: [00 A4 04 00 0E 31 50 41 59 2E 53 59 53 2E 44 44 46 30 31 00]
DEBUG:emv.transmission:Rx: [], SW1: 6a, SW2: 82
Traceback (most recent call last):
File "/usr/local/bin/emvtool", line 11, in
load_entry_point('emv==1.0.9', 'console_scripts', 'emvtool')()
File "/usr/local/lib/python3.6/dist-packages/emv/command/client.py", line 46, in run
cli(obj={})
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/emv/command/client.py", line 131, in info
apps = card.list_applications()
File "/usr/local/lib/python3.6/dist-packages/emv/card.py", line 30, in list_applications
res = self.tp.exchange(SelectCommand("1PAY.SYS.DDF01"))
File "/usr/local/lib/python3.6/dist-packages/emv/transmission.py", line 52, in exchange
res = RAPDU.unmarshal(data + [sw1, sw2])
File "/usr/local/lib/python3.6/dist-packages/emv/protocol/response.py", line 32, in unmarshal
raise obj
emv.protocol.response.ErrorResponse: <ErrorResponse: "Wrong parameter(s) P1 P2; file not found">
emv@ubuntu:~$

Shiny new barclays card (old one runs out Oct 31st 2021) - can't generate cap

emvtool doesn't seem to like this new card (was fine with the old one), it outputs a stacktrace followed by:

KeyError: (159, 85)

listapps outputs this:

│ Index │ Label        │ ADF                    │
├───────┼──────────────┼────────────────────────┤
│ 0     │ "LINK ATM"   │ [A0 00 00 00 29 10 10] │
│ 1     │ "Visa Debit" │ [A0 00 00 00 03 10 10] │
│ 2     │ "BARCLAYS"   │ [A0 00 00 00 03 80 02] │
└───────┴──────────────┴────────────────────────┘

Anything else I can try/poke? Where are the KeyErrors defined?

Unable to generate CAP codes for Barclays debit card

Hi there,

If I use the incorrect PIN, python-emv recognises this and bails.

$ emvtool -p 0000 cap
Invalid PIN

…but when I use the correct PIN, python-emv is unable to generate the CAP code.

$ emvtool -p 1111 cap
Traceback (most recent call last):
  File "/Users/htw/.pyenv/versions/3.6.4/bin/emvtool", line 11, in <module>
    sys.exit(run())
  File "/Users/htw/.pyenv/versions/3.6.4/lib/python3.6/site-packages/emv/command/client.py", line 46, in run
    cli(obj={})
  File "/Users/htw/.pyenv/versions/3.6.4/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/htw/.pyenv/versions/3.6.4/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/htw/.pyenv/versions/3.6.4/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/htw/.pyenv/versions/3.6.4/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/htw/.pyenv/versions/3.6.4/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/htw/.pyenv/versions/3.6.4/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/htw/.pyenv/versions/3.6.4/lib/python3.6/site-packages/emv/command/client.py", line 151, in cap
    click.echo(card.generate_cap_value(ctx.obj['pin'], challenge=challenge, value=amount))
  File "/Users/htw/.pyenv/versions/3.6.4/lib/python3.6/site-packages/emv/card.py", line 118, in generate_cap_value
    self.verify_pin(pin)
  File "/Users/htw/.pyenv/versions/3.6.4/lib/python3.6/site-packages/emv/card.py", line 89, in verify_pin
    res = self.tp.exchange(VerifyCommand(pin))
  File "/Users/htw/.pyenv/versions/3.6.4/lib/python3.6/site-packages/emv/transmission.py", line 51, in exchange
    res = RAPDU.unmarshal(data + [sw1, sw2])
  File "/Users/htw/.pyenv/versions/3.6.4/lib/python3.6/site-packages/emv/protocol/response.py", line 32, in unmarshal
    raise obj
emv.protocol.response.ErrorResponse: <ErrorResponse: "Command not allowed; conditions of use not satisfied">

EMV-CAP is able to successfully generate a code, so it seems the card is okay. I've created this as a separate issue since #6 appears to be related to different error messages.

emvtool info fails to display card info and errors

When checking for card info, I get an error:

iann-laptop ~ # emvtool info
Traceback (most recent call last):
  File "/usr/local/bin/emvtool", line 11, in <module>
    sys.exit(run())
  File "/usr/local/lib/python2.7/dist-packages/emv/command/client.py", line 37, in run
    EMVClient().run()
  File "/usr/local/lib/python2.7/dist-packages/emv/command/client.py", line 75, in run
    self.args.func()
  File "/usr/local/lib/python2.7/dist-packages/emv/command/client.py", line 92, in card_info
    apps = card.list_applications()
  File "/usr/local/lib/python2.7/dist-packages/emv/card.py", line 24, in list_applications
    res = self.tp.exchange(SelectCommand('1PAY.SYS.DDF01'))
  File "/usr/local/lib/python2.7/dist-packages/emv/transmission.py", line 53, in exchange
    res = RAPDU.unmarshal(data + [sw1, sw2])
  File "/usr/local/lib/python2.7/dist-packages/emv/protocol/response.py", line 34, in unmarshal
    raise obj
emv.protocol.response.ErrorResponse: <ErrorResponse: "Unknown error: 6d 00">

I guess that's back from one of the underlying libs. pcsc_scan tells me:

Possibly identified card (using /usr/share/pcsc/smartcard_list.txt):
3B 6E 00 00 80 31 80 66 B0 84 0C 01 6E 01 83 00 90 00
        Nordea (a Skandinavian bank) eID card
        http://linux.fi/wiki/Nordea_eID

Not sure if that info is helpful or not :/ Is there any other info I can provide to assist with debugging?

I'm afraid my Python is pretty much zero :(

Thanks for any help, Ian.

Error in CAP generation: Application data doesn't include CDOL1 field

Error in CAP generation: Application data doesn't include CDOL1 field: {
(57) Track 2 Equivalent Data: [], 
([5F 20]) Cardholder Name: "", 
([9F 1F]) Track 1 Discretionary Data: [], 
([5F 25]) Application Effective Date: 19/04/01, 
([5F 24]) Application Expiration Date: 22/03/31, 
(5A) Application Primary Account Number (PAN): , 
([5F 34]) Application Primary Account Number (PAN) Sequence Number: 0, 
([9F 07]) Application Usage Control: <AUC: Valid for international cash transactions>, 
(8E) Cardholder Verification Method (CVM) List: <CVM List x: 0, y: 0, rules: If terminal supports the CVM, Plaintext PIN verification performed by ICC. Else, fail verification.; If terminal supports the CVM, Enciphered PIN verified online; If terminal supports the CVM, Enciphered PIN verified online; Always, Plaintext PIN verification performed by ICC>, 
([9F 0D]) Issuer Action Code - Default: [F0 60 EC 28 00], 
([9F 0E]) Issuer Action Code - Denial: [00 10 00 00 00], 
([9F 0F]) Issuer Action Code - Online: [F0 68 FC F8 00], 
([5F 28]) Issuer Country Code: GB}

This seems to only have the appdata from the first time but the CDOL data is listed with emvtool info within the second file:

┌File: 2,2┬─────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────────┐
│ Tag     │ Name                                            │ Value                                                                           │
├─────────┼─────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
│ [9F 08] │ Application Version Number                      │ [00 8D]                                                                         │
│ [9F 42] │ Application Currency Code                       │ GBP                                                                             │
│ [5F 30] │ Service Code                                    │ [02 23]                                                                         │
│ [9F 44] │ Application Currency Exponent                   │ 2                                                                               │
│ [8C]    │ Card Risk Management Data Object List 1 (CDOL1) │ DOL([(([9F 02]) Amount, Authorised, 6), (([9F 03]) Amount, Other (Numeric), 6), │
│         │                                                 │ (([9F 1A]) Terminal Country Code, 2), ((95) Terminal Verification Results, 5),  │
│         │                                                 │ (([5F 2A]) Transaction Country Code, 2), ((9A) Transaction Date, 3), ((9C)      │
│         │                                                 │ Transaction Type, 1), (([9F 37]) Unpredictable Number, 4)])                     │
│ [8D]    │ Card Risk Management Data Object List 2 (CDOL2) │ DOL([((8A) Authorisation Response Code, 2), (([9F 02]) Amount, Authorised, 6),  │
│         │                                                 │ (([9F 03]) Amount, Other (Numeric), 6), (([9F 1A]) Terminal Country Code, 2),   │
│         │                                                 │ ((95) Terminal Verification Results, 5), (([5F 2A]) Transaction Country Code,   │
│         │                                                 │ 2), ((9A) Transaction Date, 3), ((9C) Transaction Type, 1), (([9F 37])          │
│         │                                                 │ Unpredictable Number, 4)])                                                      │
└─────────┴─────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────────────────────┘

Gives consistently 'wrong' response code with Barclays 'authentication' card

As above - fails with the online-only auth card. Works fine with pinsentry machine
Output of 'emvtool listapps' below as requested
┌Applications────────┬────────────────────────┐
│ Index │ Label │ ADF │
├───────┼────────────┼────────────────────────┤
│ 0 │ "BARCLAYS" │ [A0 00 00 00 45 31 16] │
│ 1 │ "BARCLAYS" │ [A0 00 00 02 04 00 00] │
└───────┴────────────┴────────────────────────┘

emvtool info "list index out of range"

Running against HEAD, I get a "IndexError: list index out of range" error:

[lukegb@porcorosso:~/Projects/nixpkgs]$ ./result/bin/emvtool info

1PAY.SYS.DDF01 (Index of apps for chip payments)
┌FCI Proprietary Data──────────┬───────┐
│ Tag  │ Name                  │ Value │
├──────┼───────────────────────┼───────┤
│ [88] │ Short File Identifier │ [01]  │
└──────┴───────────────────────┴───────┘
┌File: 1,1────────────────────┬─────────────────────────────────────────────────────────────────────────────────┐
│ Tag  │ Name                 │ Value                                                                           │
├──────┼──────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤
│ [61] │ Application Template │ { (4F) Application Dedicated File (ADF) Name: [A0 00 00 00 03 10 10],  (50)     │
│      │                      │ Application Label: "Visa Debit",  (87) Application Priority Indicator: 3,  (73) │
│      │                      │ Directory Discretionary Template: { ([9F 0A]) Application Selection Registered  │
│      │                      │ Proprietary Data: <ASRPD: Electronic Product Identification: Debit>}}           │
└──────┴──────────────────────┴─────────────────────────────────────────────────────────────────────────────────┘
┌File: 1,2────────────────────┬────────────────────────────────────────────────────────────────────────┐
│ Tag  │ Name                 │ Value                                                                  │
├──────┼──────────────────────┼────────────────────────────────────────────────────────────────────────┤
│ [61] │ Application Template │ { (4F) Application Dedicated File (ADF) Name: [A0 00 00 00 26],  (50)  │
│      │                      │ Application Label: "NBS ATM",  (87) Application Priority Indicator: 1} │
└──────┴──────────────────────┴────────────────────────────────────────────────────────────────────────┘
┌File: 1,3────────────────────┬─────────────────────────────────────────────────────────────────────────────┐
│ Tag  │ Name                 │ Value                                                                       │
├──────┼──────────────────────┼─────────────────────────────────────────────────────────────────────────────┤
│ [61] │ Application Template │ { (4F) Application Dedicated File (ADF) Name: [A0 00 00 00 29 10 10],  (50) │
│      │                      │ Application Label: "LINK ATM",  (87) Application Priority Indicator: 2}     │
└──────┴──────────────────────┴─────────────────────────────────────────────────────────────────────────────┘
┌File: 1,4────────────────────┬─────────────────────────────────────────────────────────────────────────────┐
│ Tag  │ Name                 │ Value                                                                       │
├──────┼──────────────────────┼─────────────────────────────────────────────────────────────────────────────┤
│ [61] │ Application Template │ { (4F) Application Dedicated File (ADF) Name: [A0 00 00 00 03 80 02],  (50) │
│      │                      │ Application Label: "VISA Auth",  (87) Application Priority Indicator: 0}    │
└──────┴──────────────────────┴─────────────────────────────────────────────────────────────────────────────┘
Traceback (most recent call last):
  File "/nix/store/4l6sm2xpfh5mc5fp8ddz3znjwyp4p76i-python3.8-python-emv-1.0.10/bin/.emvtool-wrapped", line 9, in <module>
    sys.exit(run())
  File "/nix/store/4l6sm2xpfh5mc5fp8ddz3znjwyp4p76i-python3.8-python-emv-1.0.10/lib/python3.8/site-packages/emv/command/client.py", line 46, in run
    cli(obj={})
  File "/nix/store/xl89fr1rakb0n3ydhgd69bxig5hpb257-python3.8-click-7.1.2/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/nix/store/xl89fr1rakb0n3ydhgd69bxig5hpb257-python3.8-click-7.1.2/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/nix/store/xl89fr1rakb0n3ydhgd69bxig5hpb257-python3.8-click-7.1.2/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/nix/store/xl89fr1rakb0n3ydhgd69bxig5hpb257-python3.8-click-7.1.2/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/nix/store/xl89fr1rakb0n3ydhgd69bxig5hpb257-python3.8-click-7.1.2/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/nix/store/xl89fr1rakb0n3ydhgd69bxig5hpb257-python3.8-click-7.1.2/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/nix/store/4l6sm2xpfh5mc5fp8ddz3znjwyp4p76i-python3.8-python-emv-1.0.10/lib/python3.8/site-packages/emv/command/client.py", line 134, in info
    render_app(card, "1PAY.SYS.DDF01", redact)
  File "/nix/store/4l6sm2xpfh5mc5fp8ddz3znjwyp4p76i-python3.8-python-emv-1.0.10/lib/python3.8/site-packages/emv/command/client.py", line 116, in render_app
    rec = card.read_record(j, sfi=i).data
  File "/nix/store/4l6sm2xpfh5mc5fp8ddz3znjwyp4p76i-python3.8-python-emv-1.0.10/lib/python3.8/site-packages/emv/card.py", line 94, in read_record
    return self.tp.exchange(ReadCommand(record_number, sfi))
  File "/nix/store/4l6sm2xpfh5mc5fp8ddz3znjwyp4p76i-python3.8-python-emv-1.0.10/lib/python3.8/site-packages/emv/transmission.py", line 52, in exchange
    res = RAPDU.unmarshal(data + [sw1, sw2])
  File "/nix/store/4l6sm2xpfh5mc5fp8ddz3znjwyp4p76i-python3.8-python-emv-1.0.10/lib/python3.8/site-packages/emv/protocol/response.py", line 27, in unmarshal
    obj.data = TLV.unmarshal(data[:-2])
  File "/nix/store/4l6sm2xpfh5mc5fp8ddz3znjwyp4p76i-python3.8-python-emv-1.0.10/lib/python3.8/site-packages/emv/protocol/structures.py", line 56, in unmarshal
    length, length_len = read_length(data[i:])
  File "/nix/store/4l6sm2xpfh5mc5fp8ddz3znjwyp4p76i-python3.8-python-emv-1.0.10/lib/python3.8/site-packages/emv/protocol/data.py", line 70, in read_length
    length = (length << 8) + data[i + j]
IndexError: list index out of range

Issuer Proprietary Bitmap still not found

Thanks, needed manual uninstall first 👍
emvtool version
1.0.12

But not supported card still unfortunately, cap generates an error:

image

Traceback (most recent call last):
File "/usr/local/bin/emvtool", line 8, in
sys.exit(run())
File "/usr/local/lib/python3.9/site-packages/emv/command/client.py", line 46, in run
cli(obj={})
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/emv/command/client.py", line 190, in cap
click.echo(card.generate_cap_value(pin, challenge=challenge, value=amount))
File "/usr/local/lib/python3.9/site-packages/emv/card.py", line 190, in generate_cap_value
return get_cap_value(resp, app_data[Tag.IPB], psn)
KeyError: (159, 86)

Originally posted by @kababoom in #20 (comment)

PAN zeros incorrectly omitted

In some cases, zeros are omitted from inside a PAN. I'm not going to include an example here, for obvious reasons ;)

Method for determining which app is responsible for CAP

In card.py, you note:

# We're selecting the last app on the card here, which on Barclays
# cards seems to always be the Barclays one.
#
# It would be good to work out what logic to use to work out
# which app is responsible for CAP.

From my research, you can just select the app with ADF [A0 00 00 00 03 80 02] which will always be the bank-specific app, i.e. the one responsible for CAP.

emvtool info fails with `assert connection.getProtocol() == connection.T0_protocol AssertionError

Hi,
Tried with a ACS ACR122U and followed https://ludovicrousseau.blogspot.com/2013/11/linux-nfc-driver-conflicts-with-ccid.html to get pcscd to run.

$ emvtool info
Traceback (most recent call last):
  File "/home/hamstah/repos/nfc/venv/bin/emvtool", line 10, in <module>
    sys.exit(run())
  File "/home/hamstah/repos/nfc/venv/lib/python3.6/site-packages/emv/command/client.py", line 46, in run
    cli(obj={})
  File "/home/hamstah/repos/nfc/venv/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/hamstah/repos/nfc/venv/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/hamstah/repos/nfc/venv/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/hamstah/repos/nfc/venv/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/hamstah/repos/nfc/venv/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/hamstah/repos/nfc/venv/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/hamstah/repos/nfc/venv/lib/python3.6/site-packages/emv/command/client.py", line 109, in info
    card = get_reader(ctx.obj['reader'])
  File "/home/hamstah/repos/nfc/venv/lib/python3.6/site-packages/emv/command/client.py", line 38, in get_reader
    return Card(smartcard.System.readers()[reader].createConnection())
  File "/home/hamstah/repos/nfc/venv/lib/python3.6/site-packages/emv/card.py", line 16, in __init__
    self.tp = TransmissionProtocol(connection)
  File "/home/hamstah/repos/nfc/venv/lib/python3.6/site-packages/emv/transmission.py", line 17, in __init__
    assert connection.getProtocol() == connection.T0_protocol
AssertionError

Tried a few different cards (visa, mastercard) with the same result

Thanks

error with cap

emvtool info works fine.

emvtool -p 0000 cap errors:

File "/Users/charles/Library/Python/3.6/lib/python/site-packages/emv/command/client.py", line 129, in cap
value=self.args.amount))
File "/Users/charles/Library/Python/3.6/lib/python/site-packages/emv/card.py", line 88, in generate_cap_value
self.select_application(apps[-1][Tag.ADF_NAME])
KeyError: -1

I haven’t a clue about Python, so apologies if this is a problem with my setup. macOS 10.13.4, with libpcsclite pre-installed as part of the OS.

This is a fantastic project! Keep up the great work.

Unable to fetch card data

On nearly all my cards I'm getting Unable to fetch card data: <ErrorResponse: "Referenced data (data objects) not found"> after Fetching card data....

All the cards I've tested are issued in Canada. Cards without MasterCard or Visa (credit) seem to work. e.g. Visa Debit and Interac work fine.

Seems to be similar to #3. Any ideas?

Thanks!

Processing Options Data Object List (PDOL) - last 2 bytes are missing.

Hello,

I have started using the project with contactless cards.
I found an issue when processing Select Application Response:
6f:33:84:07:a0:00:00:00:03:20:10:a5:28:50:09:56:49:53:41:20:43:41:52:44:9f:38:1a:9f:66:04:9f:02:06:9f:03:06:9f:1a:02:95:05:5f:2a:02:9a:03:9c:01:9f:37:04:9a:03:90:00

It is decoded like this:

<SuccessResponse: "Process completed", data: {
(6F) FCI Template: {
(84) Dedicated File (DF) Name: [A0 00 00 00 03 20 10],
(A5) FCI Proprietary Template: {
(50) Application Label: "VISA CARD",
([9F 38]) Processing Options Data Object List (PDOL): DOL([([9F 66], 4), (([9F 02]) Amount, Authorised, 6), (([9F 03]) Amount, Other (Numeric), 6), (([9F 1A]) Terminal Country Code, 2), ((95) Terminal Verification Results, 5), (([5F 2A]) Transaction Country Code, 2), ((9A) Transaction Date, 3), ((9C) Transaction Type, 1), (([9F 37]) Unpredictable Number, 4)])}}}>

However when I decode the respose with other tool the PDOL is like this:
9F66049F02069F03069F1A0295055F2A029A039C019F37049A03

So it looks like python-emv is missing last 2 bytes : last tag(9A) indicating length 03.

Would you please check this?

Best Regards,
Przemobe

Support for french Crédit Coopératif CAP

Hello,

I just tried emvtool -p XXXX cap with my card and it didn't work.

My setup

I'm running Debian Bookworm with an internal smartcard reader.

This is how i installed emvtool
sudo apt install python3-full build-essential swig libpcsclite-dev python3-pip python3-dev python3-pip
cd folder/
python3 -m venv .venv
.venv/bin/pip install emv

what worked

.venv/bin/emvtool info spitted a lot of info, that I could also see with cardpeek.

what didn't work

.venv/bin/emvtool -p XXXX cap threw an error ending with emv.protocol.response.ErrorResponse: <ErrorResponse: "Instruction code not supported or invalid">

Do you want to work on supporting that card? That'd be awesome as my bank requires me to carry a CAP device all the time :)
What infos would you need then?

Thanks a lot for the hard work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.