pysim Fakemagicsim problem + workaround Fwd: SIM Card Reader Problem!!

Message ID 58075B91.2040900@olifantasia.com
State New
Headers show

Commit Message

Martin Dudok van Heel Oct. 19, 2016, 11:40 a.m.
Second try. (I already sent this mail yesterday, but it did not appear 
in the mailinglist. I do not know why. Maybe because I attached a file 
(a patch))

Hi all,

This is my first post to the OpenBSC mailinglist.

I had a problem with the latest pysim version giving errors while trying 
to program 2G (Fake)MagicSIM cards.
This had worked fine in the past with an older release from 2011.
I tried al lot of versions in between.
I was finally able to narrow it down to the commit that broke 
compatibility with (fake)magicsim:

http://cgit.osmocom.org/pysim/commit/pySim/commands.py?id=8c1b33c439fef423c3536e9243035722c52aba4c 

The comment with this comit is: "Do not return the FCI information while
selecting a file
The sysmoUSIM-SJS1 card does not support returning the FCI information.
Plus, the FCI information are not used anyway."

If I revert the change with attached patch, it works again.

But it may break sysmoUSIM-SJS1 compatibility.
I am not sure on how to test whether the programming of sysmoUSIM-SJS1 
still works fine and if the SIMS themselves then will still work as 
expected with OpenBSC or OpenBTS or OpenAirinterface.

If the code needs to stay in for sysmoUSIM-SJS1 then we probably need 
somehing like the pseudocode below:

if carttype is fakemagicsim:
    "a4000002"
elif  cardtype is sysmoUSIM-SJS1:
    "a4000C02"
else:
    #What should be the default for the other cards?

Or is there another solution?

With best regards,

Martin Dudok van Heel


This is the patch inline (attaching it as a file, blocked my email from 
going through)
mdvh_pysim_make_fakesim_work_again_patch_2016081201.diff

                 return rv


On 12-08-16 09:50, Holger Freyther wrote:
>> On 12 Aug 2016, at 09:18, Rene Groothuis wrote:
>>
>> Hello,
> Hi!
>
>
>> I’m still having problems, sorry to report this. Below the log file 
>> of different combinations:
>>
>
>> I’ve used different (same model) SIM cards. I’ve reinstated the USB 
>> reader. Tried in different USB ports. No Luck.
>>
>> What am I doing wrong, can you please help?
>>
>>
> Sysmocom sold the last 16in1 magicsim in 2012? Did you buy these cards 
> from us? Maybe this specific one is just broken? Maybe try an older 
> version of pySIM? E.g. maybe some of the patches required for the 
> sysmoUSIM-SJS1 broke magicsim support?
>
> In the future you could consider getting the sysmoUSIM-SJS1 from us, 
> they are of way higher quality than the Chinese (GRcard, magicsim, 
> etc.) ones. For emergencies like these it might make sense for you to 
> get a support contract from sysmocom as well.
>
> good luck
>
>     holger
>
>

Comments

Neels Hofmeyr Oct. 19, 2016, 12:12 p.m. | #1
Dear Martin,

thanks for your report. The failure is known and we've actually posted about
this just the past two days.

I have now created an issue for this: https://osmocom.org/issues/1828

~Neels

Patch

diff --git a/pySim/commands.py b/pySim/commands.py
index 721b3d4..b7fb77f 100644
--- a/pySim/commands.py
+++ b/pySim/commands.py
@@ -41,7 +41,7 @@  class SimCardCommands(object):
         def select_file(self, dir_list):
                 rv = []
                 for i in dir_list:
-                       data, sw = 
self._tp.send_apdu_checksw(self.cla_byte + "a4000C02" + i)
+                       data, sw = 
self._tp.send_apdu_checksw(self.cla_byte + "a4000002" + i)
                         rv.append(data)