Following up

On Mon, Jan 17, 2022 at 10:35 AM Sabyrzhan Tasbolatov
<[email protected]> wrote:
>
> Hello,
>
> Sorry, for the late reply. (replying again in new thread as prev mails 
> failed).
> Quoted prev mails in quotes below.
>
> >> Which is "your test sim".  Can you share the make and model?
>
> It's a sysmoUSIM-SJS1, I believe.
>
> I'm receiving 9000 for INSTALL for load, and for consequent LOAD
> commands 9000 as well. Only for the last INSTALL for install, I'm
> getting 6A88 (reference data not found). I think, the issue is in
> AIDs. I'm trying to figure out if I should use arbitrary bytes for AID
> or construct AID (which includes RID + RIX) the same way as
> existing Load Files, Applets' AID are on the SIM card?
>
> I'm using d07002CA44 from this https://github.com/mrlnc/HelloSTK2,
> I believe that should be reason for the 6A88 error code.
>
> Could you please assist?
>
> Here is my Install for Install Python3 code:
> --
> def install_install_make_selectable(self, exe_rid="d07002CA44",
>         module_aid="d07002CA44900101",
>         app_aid="d07002CA44900101"):
>         apdu = "".join([
>             "80",   # CLS
>             "e6",   # INSTR
>             "0c",   # p1 ; for install (b3=1) ; for make selectable (b4=1)
>             "00",   # p2
>             "%02x", # p3 ; Lc
>         ])
>         # 11.5.2.3.2, page 170
>         data = "".join([
>             "%02x" % int(len(exe_rid)/2),
>             exe_rid,    # V, executable Load file AID / load file AID
>             "%02x" % int(len(module_aid)/2),
>             module_aid, # V, executable Module AID / class file AID
>             "%02x" % int(len(app_aid)/2),
>             app_aid,    # V, Application AID / instance AID
>
>             "0100",     # L privileges ; V=00, 11.1.2 Privileges
> Coding, page 146
>             "%02x",     # L Install Parameters field
>         ])
>         system_params_v = "".join([
>             "c802",     # TL - non-volatile memory quota
>             "00ff",     # V
>             "c702",     # TL - volatile memory quota
>             "00ff",
>         ])
>         install_params_tl = "".join([
>             "EF",       # T - System Specific Parameters
>             "%02x"
>         ])
>
>         install_params_v =  ""
>         install_params_v += system_params_v
>
>         install_params_v += "".join([
>             # ETSI 102 226, page 23
>             # 8.2.1.3.2.1   Coding of the SIM File Access and Toolkit
> Application Specific Parameters
>             "ca",
>             "%02x",     # TL
>         ])
>         toolkit_app_params = "".join([
>             "01",       # L of access domain
>
>             ##
>             ## Access Domain
>             ## 00 - full access
>             ## 01 - APDU access (reserved for 2G; see 3GPP TS 31 116)
>             ## 02 - UICC access (reserved for 3G)
>             ## ff - no access
>             ##
>             "ff",       # V access domain
>
>             "01",       # V priority
>             "00",       # V max timers
>             "0f",       # V max menu text
>             "02",       # V max menu entries
>             "0000" * int("02"),
>             "00",   # max number of channels for this application instance
>             "00",   # length of MSL
>         ])
>         install_params_v = install_params_v %
> int(len(toolkit_app_params)/2) + toolkit_app_params
>
>         ### C9 - Application Specific Parameters (none?)
>         applet_specific_params_v = "".join([
>             ""
>         ])
>         applet_specific_params_tlv = "".join([
>             "c9",
>             "%02x" % int(len(applet_specific_params_v)/2),
>             applet_specific_params_v
>         ])
>         install_params_v += applet_specific_params_tlv
>
>         install_params = install_params_tl %
> int(len(install_params_v)/2) + install_params_v
>         data = data % int(len(install_params)/2) + install_params
>         data += "00" # load token
>         apdu = apdu % int(len(data)/2) + data
>         apdu += "00c0000000"    # C-MAC
>         return apdu
>
> --
> > On Dec 24, 2021, 2:51 AM, Sabyrzhan Tasbolatov wrote:
> > Hello,
> >
> > I need help with installing the HelloWorld.cap applet in my test SIM.
> > I know how to construct APDUs and osmocom's shadysim.py,
> > does not work properly for me. So I've written the script myself.
> >
> > https://gist.github.com/Novitoll/2d8146b85f4384eb4dd039eb8116d1ed
> >
> > GP "Card Specification – Public Release v2.3.1".
> >
> > 1. Install for LOAD, Data = 00, SW = 9000
> > 2. LOAD 0, SW = 9000
> > 3. LOAD 1, SW = 9000
> > 4. LOAD 2, SW = 9000
> > 5. LOAD 3, SW = 9000, final
> > 6. Install for install and make selectable, SW = 6988 (Reference data not 
> > found)
> >
> > Trying to figure out where the issue is.
> > I've tried to re-use `install_app` function from shadysim.py - same result.
> >
> > I'm using this https://github.com/mrlnc/HelloSTK2/blob/main/HelloSTK2.cap
> >
> > Could anyone assist?
>
> --
> >> On Tue, Jan 4, 6:30 PM, Harald Welte wrote:
> >> Hi Sabr,
>
> >> On Mon, Jan 03, 2022 at 03:51:54PM +0600, Sabyrzhan Tasbolatov wrote:
> >>> Following up
> >>
> >>I didn't see your original mail,  sorry.
> >>
> >>> > I need help with installing the HelloWorld.cap applet in my test SIM.
> >>
> >>Which is "your test sim".  Can you share the make and model?
> >>
> >>> > I know how to construct APDUs and osmocom's shadysim.py
> >>> > <https://git.osmocom.org/sim/sim-tools/tree/shadysim/shadysim.py>,
> >>> > does not work properly for me.
> >>
> >>please note that different cards have different expectations (and bugs) on 
> >>the exact
> >>parameters to load applets.   Also, shadysim is a "early proof of concept"
> >>and not something that intended to be a full implementation and/or
> >>support a wide variety of cards with related workarounds, etc.



-- 
         Sabr

Reply via email to