Change in pysim[master]: pysim-prog: also allow raw hex adm pins besides numeric ascii

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Jun 13 10:22:30 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9587 )

Change subject: pysim-prog: also allow raw hex adm pins besides numeric ascii
......................................................................

pysim-prog: also allow raw hex adm pins besides numeric ascii

At the momemnt pysim takes the supplied ADM pin number and interprets
it as ascii string. This ascii string (max 8 digitis) is then padded
with 0xff bytes if necessary and sent to the card.

This limits the range of possible ADM keys and it is not possible
to deal with situataions where the ADM pin consists of arbitrary
bytes. At the momemnt pysim-prog forbis anything that is longer
than 8 digits. Lets also check if there are 16 digits and if yes
interpret them as raw bytes.

- when the adm pin is 16 digits long, interpret the string as raw
  bytes (hex).

Change-Id: If0ac0d328c64b57bc4d45d985a4a516930053344
Related: SYS#4245
---
M pySim-prog.py
1 file changed, 7 insertions(+), 4 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved; Verified



diff --git a/pySim-prog.py b/pySim-prog.py
index 0c9f749..d70eac9 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -361,10 +361,13 @@
 		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)
+		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
 

-- 
To view, visit https://gerrit.osmocom.org/9587
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If0ac0d328c64b57bc4d45d985a4a516930053344
Gerrit-Change-Number: 9587
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180613/247061a2/attachment.htm>


More information about the gerrit-log mailing list