Skip to content

Commit 1a3b584

Browse files
committed
EMM: add fallback to EIA0 if invalid EIA is selected
1 parent 0dc70ce commit 1a3b584

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pycrate_mobile/TS24301_EMM.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
log('warning: CryptoMobile Python module not found, unable to handle LTE NAS security')
9494
else:
9595
_with_cm = True
96+
_with_cm_eia_unk_as_eia0 = False
9697
if hasattr(CM, 'EEA2'):
9798
_EIA = {
9899
1 : CM.EIA1,
@@ -590,8 +591,11 @@ def mac_verify(self, key=16*b'\0', dir=0, eia=0, seqnoff=0):
590591
try:
591592
EIA = _EIA[eia]
592593
except KeyError:
593-
raise(PycrateErr('EMMSecProtNASMessage.mac_verify(): invalid EIA identifier, {0}'\
594-
.format(eia)))
594+
if _with_cm_eia_unk_as_eia0:
595+
return True
596+
else:
597+
raise(PycrateErr('EMMSecProtNASMessage.mac_verify(): invalid EIA identifier, {0}'\
598+
.format(eia)))
595599
nasmsg = self[-1]
596600
if isinstance(nasmsg, Buf):
597601
nasbuf = nasmsg.get_val()
@@ -626,8 +630,12 @@ def mac_compute(self, key=16*b'\0', dir=0, eia=0, seqnoff=0):
626630
try:
627631
EIA = _EIA[eia]
628632
except KeyError:
629-
raise(PycrateErr('EMMSecProtNASMessage.mac_compute(): invalid EIA identifier, {0}'\
630-
.format(eia)))
633+
if _with_cm_eia_unk_as_eia0:
634+
self[1].set_val(b'\0\0\0\0')
635+
return
636+
else:
637+
raise(PycrateErr('EMMSecProtNASMessage.mac_compute(): invalid EIA identifier, {0}'\
638+
.format(eia)))
631639
nasmsg = self[-1]
632640
if isinstance(nasmsg, Buf):
633641
nasbuf = nasmsg.get_val()

0 commit comments

Comments
 (0)