Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to generate CAP codes for Barclays debit card #7

Open
unlobito opened this issue Jun 30, 2018 · 4 comments
Open

Unable to generate CAP codes for Barclays debit card #7

unlobito opened this issue Jun 30, 2018 · 4 comments

Comments

@unlobito
Copy link

unlobito commented Jun 30, 2018

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.

@russss
Copy link
Owner

russss commented Jul 11, 2018

Can you show me the result of emvtool listapps please?

@unlobito
Copy link
Author

Apologies for the delay, the requested output is as follows.

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

@russss
Copy link
Owner

russss commented Jul 23, 2018

That's curious. My suspicion was that it was selecting the wrong app - at the moment it is hardcoded to select the last app on the card, but as far as I know "BARCLAYS" is the correct app.

python-emv is a bit of a mess, so it's very hard to work out what it's doing differently.

I'm not sure I'm going to be able to work this out without access to a problematic card, but can you let me know the date of issue of the card, and whether it's an unusual card in any way?

@unlobito
Copy link
Author

Not an unusual card as far as I know (just a reissue due to name change). Issued early October 2017. I've also reproduced this issue with a card issued early September 2015 (although, compared to this one, it lacks contactless and only has the A0 00 00 00 03 10 10 application)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants