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/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9571 ) Change subject: __init__: allow wildcards in expected SW for send_apdu_checksw() ...................................................................... __init__: allow wildcards in expected SW for send_apdu_checksw() The method send_apdu_checksw() is used to check the SW of the final response against some pre defined value. However, in many cases the last two digits of the SW are used to return varying information (e.g. length information or a more specific status info). To cover those cases it would be helfpul to define status words that contain wildcards (e.g. 61**) in order to be able to accept all SWs from 6100 to 61ff. - When the user supplies an expected SW with wildcards, mask out those digits in the response before comparing Change-Id: I5bfc0522b4228b5d9b3415f6e708abcf0da0a7b7 --- M pySim/transport/__init__.py 1 file changed, 13 insertions(+), 2 deletions(-) Approvals: Harald Welte: Looks good to me, approved; Verified diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py index dd04bba..0a71117 100644 --- a/pySim/transport/__init__.py +++ b/pySim/transport/__init__.py @@ -77,12 +77,23 @@ """send_apdu_checksw(pdu,sw): Sends an APDU and check returned SW pdu : string of hexadecimal characters (ex. "A0A40000023F00") - sw : string of 4 hexadecimal characters (ex. "9000") + sw : string of 4 hexadecimal characters (ex. "9000"). The + user may mask out certain digits using a '?' to add some + ambiguity if needed. return : tuple(data, sw), where data : string (in hex) of returned data (ex. "074F4EFFFF") sw : string (in hex) of status word (ex. "9000") """ rv = self.send_apdu(pdu) - if sw.lower() != rv[1]: + + # Create a masked version of the returned status word + sw_masked = "" + for i in range(0, 4): + if sw.lower()[i] == '?': + sw_masked = sw_masked + '?' + else: + sw_masked = sw_masked + rv[1][i].lower() + + if sw.lower() != sw_masked: raise RuntimeError("SW match failed ! Expected %s and got %s." % (sw.lower(), rv[1])) return rv -- To view, visit https://gerrit.osmocom.org/9571 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: I5bfc0522b4228b5d9b3415f6e708abcf0da0a7b7 Gerrit-Change-Number: 9571 Gerrit-PatchSet: 3 Gerrit-Owner: dexter <pmaier at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180618/5a1bb92e/attachment.htm>