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
This commit is contained in:
@@ -361,10 +361,13 @@ def gen_parameters(opts):
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user