aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2019-09-05 13:08:36 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2019-09-05 13:58:38 +0200
commite053da5a1498cc057aeef829b2a8b29e5cac7c14 (patch)
treebf2319c8043193071f3b85e9ac2e82d9be024a60
parent164b963dd2688600fb0107358642d47f270acca7 (diff)
pySim-prog: generate a pin_adm from pin_adm_hex also for CSV files
When reading CSV files we currently have no option to provide a pin_adm_hex field like we already have it as commandline option. Lets add an option pin_adm_hex for this. Change-Id: I53e8d666d26a06f580725a8443a335643d10192c
-rwxr-xr-xpySim-prog.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/pySim-prog.py b/pySim-prog.py
index 8abce0a..13e8bb5 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -485,6 +485,21 @@ def read_params_csv(opts, imsi=None, iccid=None):
pin_adm = ''.join(['%02x'%(ord(x)) for x in row['adm1']])
if pin_adm:
row['pin_adm'] = rpad(pin_adm, 16)
+
+ # If the CSV-File defines a pin_adm_hex field use this field to
+ # generate pin_adm from that.
+ pin_adm_hex = row.get('pin_adm_hex')
+ if pin_adm_hex:
+ if len(pin_adm_hex) == 16:
+ row['pin_adm'] = pin_adm_hex
+ # Ensure that it's hex-encoded
+ try:
+ try_encode = h2b(pin_adm)
+ except ValueError:
+ raise ValueError("pin_adm_hex needs to be hex encoded using this option")
+ else:
+ raise ValueError("pin_adm_hex needs to be exactly 16 digits (hex encoded)")
+
return row