aboutsummaryrefslogtreecommitdiffstats
path: root/pySim-prog.py
diff options
context:
space:
mode:
authorJan Balke <jan@corenetdynamics.com>2015-01-26 12:22:55 +0100
committerHarald Welte <laforge@gnumonks.org>2015-08-20 13:32:56 +0200
commitc3ebd3354414f9f7df57dd82ec17548d451f9bd7 (patch)
tree525413291782eb650c0d5e9f1e60f04ed10222d2 /pySim-prog.py
parent14b350f3a1a38437eceada9a70fdb4b154ba9eac (diff)
Add PIN-ADM argument to the command line
Allow overwriting the default PIN-ADM set in the card implementation.
Diffstat (limited to 'pySim-prog.py')
-rwxr-xr-xpySim-prog.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/pySim-prog.py b/pySim-prog.py
index 5e5f063..650d8ea 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -62,6 +62,9 @@ def parse_options():
help="Card type (user -t list to view) [default: %default]",
default="auto",
)
+ parser.add_option("-a", "--pin-adm", dest="pin_adm",
+ help="ADM PIN used for provisioning (overwrites default)",
+ )
parser.add_option("-e", "--erase", dest="erase", action='store_true',
help="Erase beforehand [default: %default]",
default=False,
@@ -249,7 +252,7 @@ def derive_milenage_opc(ki_hex, op_hex):
return b2h(strxor(opc_bytes, h2b(op_hex)))
def gen_parameters(opts):
- """Generates Name, ICCID, MCC, MNC, IMSI, SMSP, Ki from the
+ """Generates Name, ICCID, MCC, MNC, IMSI, SMSP, Ki, PIN-ADM from the
options given by the user"""
# MCC/MNC
@@ -374,6 +377,14 @@ def gen_parameters(opts):
else:
opc = ''.join(['%02x' % random.randrange(0,256) for i in range(16)])
+ if opts.pin_adm is not None:
+ if len(opts.pin_adm) > 8:
+ raise ValueError("PIN-ADM needs to be <=8 digits")
+ pin_adm = ''.join(['%02x'%(ord(x)) for x in opts.pin_adm])
+ pin_adm = rpad(pin_adm, 16)
+ else:
+ pin_adm = None
+
# Return that
return {
@@ -386,6 +397,7 @@ def gen_parameters(opts):
'ki' : ki,
'opc' : opc,
'acc' : acc,
+ 'pin_adm' : pin_adm,
}