Change in pysim[master]: cards: remove unnecessary execptions.

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

dexter gerrit-no-reply at lists.osmocom.org
Fri Mar 19 17:05:12 UTC 2021


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


Change subject: cards: remove unnecessary execptions.
......................................................................

cards: remove unnecessary execptions.

The _scc.veryif_adm() method already does status word checking
internally and also raises an execption should the authentication be
unsuccessful, so we do not have to put an additional status word check +
execition when we use the method from cards.

Change-Id: I785d27e4d49a9cda1a771b56ce5ac9c1f1d1e79a
Related: OS#4963
---
M pySim/cards.py
1 file changed, 2 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/24/23424/1

diff --git a/pySim/cards.py b/pySim/cards.py
index 8b51787..c640591 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -854,8 +854,6 @@
 		if not key:
 			raise ValueError("Please provide a PIN-ADM as there is no default one")
 		(res, sw) = self._scc.verify_chv(0x0A, key)
-		if sw != '9000':
-			raise RuntimeError('Failed to authenticate with ADM key %s'%(key))
 		return sw
 
 	def program(self, p):
@@ -1045,9 +1043,7 @@
 		# authenticate as ADM1
 		if not p['pin_adm']:
 			raise ValueError("Please provide a PIN-ADM as there is no default one")
-		sw = self.verify_adm(h2b(p['pin_adm']))
-		if sw != '9000':
-			raise RuntimeError('Failed to authenticate with ADM key %s'%(p['pin_adm'],))
+		self.verify_adm(h2b(p['pin_adm']))
 
 		# TODO: Set operator name
 		if p.get('smsp') is not None:
@@ -1152,9 +1148,7 @@
 	def program(self, p):
 		if not p['pin_adm']:
 			raise ValueError("Please provide a PIN-ADM as there is no default one")
-		sw = self.verify_adm(h2b(p['pin_adm']))
-		if sw != '9000':
-			raise RuntimeError('Failed to authenticate with ADM key %s'%(p['pin_adm'],))
+		self.verify_adm(h2b(p['pin_adm']))
 
 		# EF.ICCID
 		# TODO: Add programming of the ICCID
@@ -1254,8 +1248,6 @@
 		if not key:
 			raise ValueError("Please provide a PIN-ADM as there is no default one")
 		(res, sw) = self._scc.verify_chv(0x0A, key)
-		if sw != '9000':
-			raise RuntimeError('Failed to authenticate with ADM key %s'%(key))
 		return sw
 
 	def program(self, p):

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I785d27e4d49a9cda1a771b56ce5ac9c1f1d1e79a
Gerrit-Change-Number: 23424
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210319/11cd85b8/attachment.htm>


More information about the gerrit-log mailing list