Change in pysim[master]: Added checks for SPN

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

herlesupreeth gerrit-no-reply at lists.osmocom.org
Tue Jan 21 13:03:01 UTC 2020


herlesupreeth has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/16977 )


Change subject: Added checks for SPN
......................................................................

Added checks for SPN

Change-Id: I35fab9a85efda2b83f221a460d31c7d41db582b0
---
M pySim-prog.py
M pySim/cards.py
2 files changed, 10 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/77/16977/1

diff --git a/pySim-prog.py b/pySim-prog.py
index 709086d..b19c24b 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -276,6 +276,12 @@
 	# Digitize MCC/MNC (5 or 6 digits)
 	plmn_digits = _mcc_mnc_digits(mcc, mnc)
 
+	name = None
+	if opts.name is not None:
+		if len(opts.name) > 16:
+			raise ValueError('Service Provider Name must max 16 characters!');
+		name = opts.name
+
 	msisdn = None
 	if opts.msisdn is not None:
 		if len(opts.msisdn) > 10*2:
@@ -424,7 +430,7 @@
 
 	# Return that
 	return {
-		'name'	: opts.name,
+		'name'	: name,
 		'iccid'	: iccid,
 		'mcc'	: mcc,
 		'mnc'	: mnc,
diff --git a/pySim/cards.py b/pySim/cards.py
index 59e4dff..bec33f7 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -613,8 +613,9 @@
 			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']))

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I35fab9a85efda2b83f221a460d31c7d41db582b0
Gerrit-Change-Number: 16977
Gerrit-PatchSet: 1
Gerrit-Owner: herlesupreeth <herlesupreeth at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200121/6077c551/attachment.htm>


More information about the gerrit-log mailing list