Hello,
I would like to propose the two changes for pysim, the first is for fixing the sysmo-usim-sjs1 support and the second fixes the missing support for writing the ICCID to a sysmo-usim-sjs1.
If there are no major concerns with that I would like to merge the two patches to master.
Repo: https://git.osmocom.org/pysim Branch: pmaier/fixfci
regards, Philipp Maier
Philipp Maier (2): Fix select control parameter fix writing of ICCID for sysmo-usim-sjs1
pySim/cards.py | 15 ++++++++------- pySim/commands.py | 11 +++++++++-- 2 files changed, 17 insertions(+), 9 deletions(-)
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)
On Thu, Mar 23, 2017 at 01:07:16PM +0100, Philipp Maier wrote:
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)
This shows me that the patch is not based on the current master. I fixed the missing newline in another patch.
...maybe let's wait a bit, if we're moving this to gerrit soon you won't need to send another mail.
~N
The programming procedure for sysmo-usim-sjs1 lacks writing the ICCID. This commit adds the missing call to update_binary() --- pySim/cards.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/pySim/cards.py b/pySim/cards.py index fafc55f..925c5e6 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -434,20 +434,20 @@ class SysmoUSIMSJS1(Card):
def program(self, p):
+ # authenticate as ADM using default key (written on the card..) + if not p['pin_adm']: + raise ValueError("Please provide a PIN-ADM as there is no default one") + self._scc.verify_chv(0x0A, h2b(p['pin_adm']))
# select MF r = self._scc.select_file(['3f00'])
+ # write EF.ICCID + data, sw = self._scc.update_binary('2fe2', enc_iccid(p['iccid'])) + # select DF_GSM r = self._scc.select_file(['7f20'])
- # authenticate as ADM using default key (written on the card..) - if not p['pin_adm']: - raise ValueError("Please provide a PIN-ADM as there is no default one") - - self._scc.verify_chv(0x0A, h2b(p['pin_adm'])) - - # set Ki in proprietary file data, sw = self._scc.update_binary('00FF', p['ki'])
On a related note: should we add pysim to https://gerrit.osmocom.org/#/admin/projects/ ?
On 23.03.2017 13:07, Philipp Maier wrote:
Hello,
I would like to propose the two changes for pysim, the first is for fixing the sysmo-usim-sjs1 support and the second fixes the missing support for writing the ICCID to a sysmo-usim-sjs1.
If there are no major concerns with that I would like to merge the two patches to master.
Repo: https://git.osmocom.org/pysim Branch: pmaier/fixfci
regards, Philipp Maier
Philipp Maier (2): Fix select control parameter fix writing of ICCID for sysmo-usim-sjs1
pySim/cards.py | 15 ++++++++------- pySim/commands.py | 11 +++++++++-- 2 files changed, 17 insertions(+), 9 deletions(-)
On Thu, Mar 23, 2017 at 01:10:04PM +0100, Max wrote:
On a related note: should we add pysim to https://gerrit.osmocom.org/#/admin/projects/ ?
+1
I can do this if we have consensus. Anyone against it?
~N
Hi Neels,
On Mon, Mar 27, 2017 at 12:47:08AM +0200, Neels Hofmeyr wrote:
On Thu, Mar 23, 2017 at 01:10:04PM +0100, Max wrote:
On a related note: should we add pysim to https://gerrit.osmocom.org/#/admin/projects/ ?
I can do this if we have consensus. Anyone against it?
Thanks for the offer. However, the "consensus" of so far two or three people (who have very little involvement in pysim) doesn't weigh much in context of the opinion of the original author and maintainer of the software, which is in this case Sylvain.
So it's primarily up to him to decide which tools he wants to use.
Please don't make any changes unless the "owner" of the respective project has explicitly requested them.
Regards, Harald
On Mon, Mar 27, 2017 at 10:27:12AM +0200, Harald Welte wrote:
I can do this if we have consensus. Anyone against it?
Please don't make any changes unless the "owner" of the respective project has explicitly requested them.
That's exactly what I meant by consensus, maybe the wrong word there... tnt, what's your opinion on gerrit?
~N
Hi,
That's exactly what I meant by consensus, maybe the wrong word there... tnt, what's your opinion on gerrit?
I think I'm going crazy. I'm like 100% sure of having answered that a week ago or so but I can't find any trace of it.
Anyway the gist of it was :
- gettit is fine - If someone wants to take over the project, I'd be happy to see it in better hands than mine. I don't use pysim on a regular basis (I have a couple of test sims, but they're programmed and I already have the parameters and no reason to change them) and don't have most of the supported cards model to test changes anyway.
Cheers,
Sylvain
Hi Sylvain,
On Mon, Mar 27, 2017 at 06:49:34PM +0200, Sylvain Munaut wrote:
I think I'm going crazy. I'm like 100% sure of having answered that a week ago or so but I can't find any trace of it.
I know the feeling. Has happened plenty of times before, and then the mail was either in the drafts folder, or I never actually wrote it and just thought of writing it. Must be the age [at least in my case] ;)
Anyway the gist of it was :
- gettit is fine
fine.
- If someone wants to take over the project, I'd be happy to see it
in better hands than mine. I don't use pysim on a regular basis (I have a couple of test sims, but they're programmed and I already have the parameters and no reason to change them) and don't have most of the supported cards model to test changes anyway.
I think this would be an ideal opportunity for one of the various new contributors part of the accelerate3g5 project (most of whom should be lurking on this list). Let's see if somebody wants to step forward for this. It's a really small and self-contained tool, and you don't need to be a low-level C guru, so I think it's actually a good candidate for somebody interested in contributing in some way.
I'm happy to send anyone interested in maintaining this utility a couple of different SIM cards (magic, sysmoSIM-GR1, sysmoUSIM-SJS1, ...). I don't think I ever had (or still have) all of the supported models, though.
Regards, Harald