aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Chemeris <Alexander.Chemeris@gmail.com>2018-01-26 15:49:49 +0900
committerAlexander Chemeris <Alexander.Chemeris@gmail.com>2018-01-26 15:49:49 +0900
commit6d4a0a1a3e9a1d9bcc5a978112bf34f11005dc16 (patch)
treef1fe095ec3255b96bbbae7fdce40ed0ae7dd8b0a
parente6d4faa6f5abe736bac1a6f3d0cdb7ea848503f0 (diff)
Add a comanda to run GSM auth algorithm.
-rw-r--r--pySim/commands.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/pySim/commands.py b/pySim/commands.py
index eba915c..1a7584b 100644
--- a/pySim/commands.py
+++ b/pySim/commands.py
@@ -100,12 +100,26 @@ class SimCardCommands(object):
r = self.select_file(ef)
return int(r[-1][4:8], 16) // int(r[-1][28:30], 16)
- def run_gsm(self, rand):
+ def run_gsm_raw(self, rand):
+ '''
+ A3/A8 algorithm in the SIM card using the given RAND.
+ This function returns a raw result tuple.
+ '''
if len(rand) != 32:
raise ValueError('Invalid rand')
self.select_file(['3f00', '7f20'])
return self._tp.send_apdu(self.cla_byte + '88000010' + rand)
+ def run_gsm(self, rand):
+ '''
+ A3/A8 algorithm in the SIM card using the given RAND.
+ This function returns a parsed ((SRES, Kc), sw) tuple.
+ '''
+ (res, sw) = self.run_gsm_raw(rand)
+ if sw != '9000':
+ return (res, sw)
+ return ((res[0:8], res[8:]), sw)
+
def reset_card(self):
return self._tp.reset_card()