diff --git a/pySim-prog.py b/pySim-prog.py index bfb40b2e..09a5d70f 100755 --- a/pySim-prog.py +++ b/pySim-prog.py @@ -274,6 +274,10 @@ def gen_parameters(opts): # Digitize MCC/MNC (5 or 6 digits) plmn_digits = _mcc_mnc_digits(mcc, mnc) + if opts.name is not None: + if len(opts.name) > 16: + raise ValueError('Service Provider Name must max 16 characters!'); + # ICCID (19 digits, E.118), though some phase1 vendors use 20 :( if opts.iccid is not None: iccid = opts.iccid diff --git a/pySim/cards.py b/pySim/cards.py index faaeca3a..022182cf 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -613,8 +613,9 @@ class SysmoUSIMSJS1(Card): data, sw = self._scc.update_binary('00F7', content) # set Service Provider Name - content = enc_spn(p['name'], True, True) - data, sw = self._scc.update_binary('6F46', rpad(content, 32)) + if p.get('name') is not None: + content = enc_spn(p['name'], True, True) + data, sw = self._scc.update_binary('6F46', rpad(content, 32)) # write EF.IMSI data, sw = self._scc.update_binary('6f07', enc_imsi(p['imsi']))