From patchwork Thu Mar 23 12:07:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Maier X-Patchwork-Id: 742642 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id 3vplft6wVZz9s3w for ; Thu, 23 Mar 2017 23:07:34 +1100 (AEDT) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 85CFF2F32C; Thu, 23 Mar 2017 12:07:33 +0000 (UTC) Authentication-Results: lists.osmocom.org; dmarc=none header.from=sysmocom.de X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a01:4f8:191:444c::2:4; helo=mail.sysmocom.de; envelope-from=pmaier@sysmocom.de; receiver=openbsc@lists.osmocom.org Authentication-Results: lists.osmocom.org; dmarc=none header.from=sysmocom.de Received: from mail.sysmocom.de (mail.sysmocom.de [IPv6:2a01:4f8:191:444c::2:4]) by lists.osmocom.org (Postfix) with ESMTP id 7A2E52F317 for ; Thu, 23 Mar 2017 12:07:26 +0000 (UTC) Received: from mail.sysmocom.de (mail.sysmocom.de [144.76.43.93]) by mail.sysmocom.de (Postfix) with ESMTP id B67252AB016; Thu, 23 Mar 2017 12:07:26 +0000 (UTC) Received: from my.box (unknown [91.65.133.89]) by mail.sysmocom.de (Postfix) with ESMTPSA id 7E3712AB014; Thu, 23 Mar 2017 12:07:26 +0000 (UTC) From: Philipp Maier To: openbsc@lists.osmocom.org, pmaier@sysmocom.de Subject: [PATCH 1/2] Fix select control parameter Date: Thu, 23 Mar 2017 13:07:16 +0100 Message-Id: <1490270837-28823-2-git-send-email-pmaier@sysmocom.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490270837-28823-1-git-send-email-pmaier@sysmocom.de> References: <1490270837-28823-1-git-send-email-pmaier@sysmocom.de> X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of OpenBSC, OsmoBSC, OsmoNITB, OsmoCSCN" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" sysmo-usim-sjs1 requires P2 to be set to 0x0C (request FCI) when using the USIM application commands. The FCI is not used by pysim anyway and might even cause problems with other cards. This commit adds a pair of get/set methods to the SimCardCommands class in order to set a default for the selection control parameters (P1, P2). (Similar to the set/get methods for the class byte) The SysmoUSIMSJS1 class now calls the setter method for the selection control parameters inside of its constructuor and sets the selection control parameter default to "000C". This way we can be sure that we only change the behaviour for sysmo-usim-sjs1 and do not break support for any other cards. --- pySim/cards.py | 1 + pySim/commands.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pySim/cards.py b/pySim/cards.py index 23352a7..fafc55f 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -425,6 +425,7 @@ class SysmoUSIMSJS1(Card): def __init__(self, ssc): super(SysmoUSIMSJS1, self).__init__(ssc) self._scc.cla_byte = "00" + self._scc.sel_ctrl = "000C" @classmethod def autodetect(kls, scc): diff --git a/pySim/commands.py b/pySim/commands.py index cb72a11..d8bd8f2 100644 --- a/pySim/commands.py +++ b/pySim/commands.py @@ -29,6 +29,7 @@ class SimCardCommands(object): def __init__(self, transport): self._tp = transport; self._cla_byte = "a0" + self._sel_ctrl = "0000" @property def cla_byte(self): @@ -37,11 +38,17 @@ class SimCardCommands(object): def cla_byte(self, value): self._cla_byte = value + @property + def sel_ctrl(self): + return self._sel_ctrl + @sel_ctrl.setter + def sel_ctrl(self, value): + self._sel_ctrl = value def select_file(self, dir_list): rv = [] for i in dir_list: - data, sw = self._tp.send_apdu_checksw(self.cla_byte + "a4000002" + i) + data, sw = self._tp.send_apdu_checksw(self.cla_byte + "a4" + self._sel_ctrl + "02" + i) rv.append(data) return rv @@ -101,4 +108,4 @@ class SimCardCommands(object): def verify_chv(self, chv_no, code): fc = rpad(b2h(code), 16) - return self._tp.send_apdu_checksw(self.cla_byte + '2000' + ('%02X' % chv_no) + '08' + fc) \ No newline at end of file + return self._tp.send_apdu_checksw(self.cla_byte + '2000' + ('%02X' % chv_no) + '08' + fc)