This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
daniel gerrit-no-reply at lists.osmocom.orgdaniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/15393
Change subject: pySim-prog: Add option for hex ADM keys
......................................................................
pySim-prog: Add option for hex ADM keys
pySim-prog would implicitly try to use the raw or hex-escaped format
depending on the length of the parameter, now there is the option "-A"
to explicitly specify the hex-escaped ADM1 key.
pysim-test.sh: Explicitly use the "-A" option to pass the hex adm1 key
for wavemobile cards
Change-Id: Id75a03482aa7f8cc3bdbb8d5967f1e8ab45c179a
---
M pySim-prog.py
M pysim-testdata/Wavemobile-SIM.data
M tests/Wavemobile-SIM.data.example
M tests/pysim-test.sh
4 files changed, 28 insertions(+), 10 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/93/15393/1
diff --git a/pySim-prog.py b/pySim-prog.py
index e00c2d0..2ac4dad 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -73,6 +73,9 @@
parser.add_option("-a", "--pin-adm", dest="pin_adm",
help="ADM PIN used for provisioning (overwrites default)",
)
+ parser.add_option("-A", "--pin-adm-hex", dest="pin_adm_hex",
+ help="ADM PIN used for provisioning, as hex string (16 characters long",
+ )
parser.add_option("-e", "--erase", dest="erase", action='store_true',
help="Erase beforehand [default: %default]",
default=False,
@@ -376,17 +379,27 @@
else:
opc = ''.join(['%02x' % random.randrange(0,256) for i in range(16)])
+
+ pin_adm = None
+
if opts.pin_adm is not None:
if len(opts.pin_adm) <= 8:
pin_adm = ''.join(['%02x'%(ord(x)) for x in opts.pin_adm])
pin_adm = rpad(pin_adm, 16)
- elif len(opts.pin_adm) == 16:
- pin_adm = opts.pin_adm
- else:
- raise ValueError("PIN-ADM needs to be <=8 digits (ascii) or exactly 16 digits (raw hex)")
- else:
- pin_adm = None
+ else:
+ raise ValueError("PIN-ADM needs to be <=8 digits (ascii)")
+
+ if opts.pin_adm_hex is not None:
+ if len(opts.pin_adm_hex) == 16:
+ pin_adm = opts.pin_adm_hex
+ # Ensure that it's hex-encoded
+ try:
+ try_encode = h2b(pin_adm)
+ except ValueError:
+ raise ValueError("PIN-ADM needs to be hex encoded using this option")
+ else:
+ raise ValueError("PIN-ADM needs to be exactly 16 digits (hex encoded)")
# Return that
return {
diff --git a/pysim-testdata/Wavemobile-SIM.data b/pysim-testdata/Wavemobile-SIM.data
index 46690b4..0c3379a 100644
--- a/pysim-testdata/Wavemobile-SIM.data
+++ b/pysim-testdata/Wavemobile-SIM.data
@@ -1,5 +1,5 @@
MCC=001
MNC=01
IMSI=001010000000102
-ADM=15E31383624FDC8A
+ADM_HEX=15E31383624FDC8A
diff --git a/tests/Wavemobile-SIM.data.example b/tests/Wavemobile-SIM.data.example
index e9ba965..bdf2d65 100644
--- a/tests/Wavemobile-SIM.data.example
+++ b/tests/Wavemobile-SIM.data.example
@@ -1,5 +1,5 @@
MCC=001
MNC=01
IMSI=001010000000102
-ADM=0123456789ABCDEF
+ADM_HEX=0123456789ABCDEF
diff --git a/tests/pysim-test.sh b/tests/pysim-test.sh
index 5af7a93..f97722d 100755
--- a/tests/pysim-test.sh
+++ b/tests/pysim-test.sh
@@ -156,9 +156,14 @@
OPC=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
IMSI=001010000000001
ADM=00000000
+ ADM_OPT="-a"
- . "$CARD_NAME.data"
- python $PYSIM_PROG -p $I -t $CARD_NAME -o $OPC -k $KI -x $MCC -y $MNC -i $IMSI -s $ICCID -a $ADM
+ source "$CARD_NAME.data"
+ if [ -n "$ADM_HEX" ]; then
+ ADM_OPT="-A"
+ ADM=$ADM_HEX
+ fi
+ python $PYSIM_PROG -p $I -t $CARD_NAME -o $OPC -k $KI -x $MCC -y $MNC -i $IMSI -s $ICCID $ADM_OPT $ADM
check_card $I $CARD_NAME
echo ""
done
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/15393
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Id75a03482aa7f8cc3bdbb8d5967f1e8ab45c179a
Gerrit-Change-Number: 15393
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillmann at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190903/816ebefc/attachment.htm>