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/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/23168 ) Change subject: cards.py: SJS1 + SJA2: Implement + Expose verify_adm() method ...................................................................... cards.py: SJS1 + SJA2: Implement + Expose verify_adm() method SJS1 and SJA2 card types don't use the generic verify_adm() method of the Card base class, so they must override it with their own methods. Only this way application code can call card.verify_adm() irrespective of the card type. Change-Id: I05f7f3280873f006310266867f04a9ce1b0a63af --- M pySim/cards.py 1 file changed, 18 insertions(+), 7 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/cards.py b/pySim/cards.py index 41dd179..dd8fe8b 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -849,12 +849,17 @@ return None return None - def program(self, p): - + def verify_adm(self, key): # authenticate as ADM using default key (written on the card..) - if not p['pin_adm']: + if not key: raise ValueError("Please provide a PIN-ADM as there is no default one") - self._scc.verify_chv(0x0A, h2b(p['pin_adm'])) + (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): + self.verify_adm(h2b(p['pin_adm'])) # select MF r = self._scc.select_file(['3f00']) @@ -1244,11 +1249,17 @@ return None return None - def program(self, p): + def verify_adm(self, key): # authenticate as ADM using default key (written on the card..) - if not p['pin_adm']: + if not key: raise ValueError("Please provide a PIN-ADM as there is no default one") - self._scc.verify_chv(0x0A, h2b(p['pin_adm'])) + (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): + self.verify_adm(h2b(p['pin_adm'])) # This type of card does not allow to reprogram the ICCID. # Reprogramming the ICCID would mess up the card os software -- To view, visit https://gerrit.osmocom.org/c/pysim/+/23168 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I05f7f3280873f006310266867f04a9ce1b0a63af Gerrit-Change-Number: 23168 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier at sysmocom.de> Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-Reviewer: pespin <pespin at sysmocom.de> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210302/c2aeee0e/attachment.htm>