Skip to content
This repository was archived by the owner on Mar 27, 2026. It is now read-only.

Commit 5f74a1b

Browse files
committed
Raise a nicer error if the IPB isn't present
1 parent 1a046d0 commit 5f74a1b

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

emv/card.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
GetProcessingOptions,
1111
VerifyCommand,
1212
)
13-
from .exc import InvalidPINException, MissingAppException
13+
from .exc import InvalidPINException, MissingAppException, EMVProtocolError
1414
from .util import decode_int
1515
from .cap import get_arqc_req, get_cap_value
1616

@@ -174,6 +174,16 @@ def generate_cap_value(self, pin, challenge=None, value=None):
174174
# of the data passed to the Get Application Cryptogram function.
175175
app_data = self.get_application_data(opts["AFL"])
176176

177+
# In some cases the IPB may not be present. EMVCAP uses the IPB:
178+
# 0000FFFFFF0000000000000000000020B938
179+
# for VISA cards which don't provide their own, but relies on a hard-coded
180+
# list of app names to work out which cards are VISA.
181+
#
182+
# It appears that Belgian cards use their own silliness.
183+
# https://github.com/zoobab/EMVCAP/blob/master/EMV-CAP#L512
184+
if Tag.IPB not in app_data:
185+
raise EMVProtocolError("Issuer Proprietary Bitmap not found in application file")
186+
177187
self.verify_pin(pin)
178188

179189
resp = self.tp.exchange(

emv/exc.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
class EMVProtocolError(Exception):
2+
pass
3+
4+
15
class InvalidPINException(Exception):
26
pass
37

48

5-
class MissingAppException(Exception):
9+
class MissingAppException(EMVProtocolError):
610
pass
711

812

9-
class CAPError(Exception):
13+
class CAPError(EMVProtocolError):
1014
pass

0 commit comments

Comments
 (0)