aboutsummaryrefslogtreecommitdiffstats
path: root/pySim-prog.py
diff options
context:
space:
mode:
authorAlexander Chemeris <Alexander.Chemeris@gmail.com>2018-01-11 13:06:43 +0900
committerAlexander Chemeris <Alexander.Chemeris@gmail.com>2018-01-11 13:06:43 +0900
commit19fffa1db760cca15a2689695f3cc14be1933513 (patch)
tree08668f1cca905c8579ebbb6b5e98d56fb7fac5c5 /pySim-prog.py
parente0d9d88cd57a50b30787a388b1fd56562b078554 (diff)
Make derive_milenage_opc and calculate_luhn publicly available through utils.py
Diffstat (limited to 'pySim-prog.py')
-rwxr-xr-xpySim-prog.py20
1 files changed, 1 insertions, 19 deletions
diff --git a/pySim-prog.py b/pySim-prog.py
index 44ca1fd..c08f43b 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -39,7 +39,7 @@ except ImportError:
from pySim.commands import SimCardCommands
from pySim.cards import _cards_classes
-from pySim.utils import h2b, swap_nibbles, rpad
+from pySim.utils import h2b, swap_nibbles, rpad, derive_milenage_opc, calculate_luhn
def parse_options():
@@ -234,24 +234,6 @@ def _dbi_binary_quote(s):
return ''.join(out)
-def calculate_luhn(cc):
- num = map(int, str(cc))
- check_digit = 10 - sum(num[-2::-2] + [sum(divmod(d * 2, 10)) for d in num[::-2]]) % 10
- return 0 if check_digit == 10 else check_digit
-
-def derive_milenage_opc(ki_hex, op_hex):
- """
- Run the milenage algorithm.
- """
- from Crypto.Cipher import AES
- from Crypto.Util.strxor import strxor
- from pySim.utils import b2h
-
- # We pass in hex string and now need to work on bytes
- aes = AES.new(h2b(ki_hex))
- opc_bytes = aes.encrypt(h2b(op_hex))
- return b2h(strxor(opc_bytes, h2b(op_hex)))
-
def gen_parameters(opts):
"""Generates Name, ICCID, MCC, MNC, IMSI, SMSP, Ki, PIN-ADM from the
options given by the user"""