Tuesday, 15 February 2011

java - Setting up SEEK for Android with Samsung Galaxy S3 -



java - Setting up SEEK for Android with Samsung Galaxy S3 -

here's background 1st:

i'm trying proof-of-concept android application check if can send apdu commands sim card applet , process response.

i'm using seek android reference implementation of open mobile api.

the application should work on samsung galaxy s3 smartphone comes open mobile api, stated here.

i not allowed utilize custom rom, nor modifications android source.

what have done far:

i've downloaded android api lvl 18 open mobile api , open mobile api packages. i've created sample application should seek access applet on sim card, described here.

on button click, i'm getting securityexception

06-23 12:57:15.620: i/hellosmartcard(5386): creating seservice object 06-23 12:57:15.655: i/seservice(5386): connected 06-23 12:57:22.525: i/hellosmartcard(5386): retrieve available readers... 06-23 12:57:22.530: i/hellosmartcard(5386): create session uicc reader... 06-23 12:57:23.275: i/hellosmartcard(5386): create logical channel within session... 06-23 12:57:23.285: e/hellosmartcard(5386): error occured: 06-23 12:57:23.285: e/hellosmartcard(5386): java.lang.securityexception: access command enforcer: access denied: ef_dir not found!! 06-23 12:57:23.285: e/hellosmartcard(5386): @ org.simalliance.openmobileapi.seservice.checkforexception(seservice.java:234) 06-23 12:57:23.285: e/hellosmartcard(5386): @ org.simalliance.openmobileapi.session.openlogicalchannel(session.java:302) 06-23 12:57:23.285: e/hellosmartcard(5386): @ com.example.testsmartcardaccess2.mainactivity$1.onclick(mainactivity.java:81) 06-23 12:57:23.285: e/hellosmartcard(5386): @ android.view.view.performclick(view.java:4475) 06-23 12:57:23.285: e/hellosmartcard(5386): @ android.view.view$performclick.run(view.java:18786) 06-23 12:57:23.285: e/hellosmartcard(5386): @ android.os.handler.handlecallback(handler.java:730) 06-23 12:57:23.285: e/hellosmartcard(5386): @ android.os.handler.dispatchmessage(handler.java:92) 06-23 12:57:23.285: e/hellosmartcard(5386): @ android.os.looper.loop(looper.java:176) 06-23 12:57:23.285: e/hellosmartcard(5386): @ android.app.activitythread.main(activitythread.java:5419) 06-23 12:57:23.285: e/hellosmartcard(5386): @ java.lang.reflect.method.invokenative(native method) 06-23 12:57:23.285: e/hellosmartcard(5386): @ java.lang.reflect.method.invoke(method.java:525) 06-23 12:57:23.285: e/hellosmartcard(5386): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1046) 06-23 12:57:23.285: e/hellosmartcard(5386): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:862) 06-23 12:57:23.285: e/hellosmartcard(5386): @ dalvik.system.nativestart.main(native method) 06-23 12:57:23.285: i/choreographer(5386): skipped 45 frames! application may doing much work on main thread.

i have org.simalliance.openmobileapi.jar dependency:

i have permission:

<uses-permission android:name="org.simalliance.openmobileapi.smartcard"/>

i have 3 applets on sim card , i'm trying phone call 1 under aid f9 f4 0f 65 18 c9 54 1e cd ad

here rough code template i'm using:

package com.example.testsmartcardaccess2; import org.simalliance.openmobileapi.channel; import org.simalliance.openmobileapi.reader; import org.simalliance.openmobileapi.seservice; import org.simalliance.openmobileapi.session; import android.app.activity; import android.os.bundle; import android.util.log; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.linearlayout; import android.widget.linearlayout.layoutparams; import android.widget.toast; public class mainactivity extends activity implements seservice.callback { private seservice seservice; private reader uuicreader; private boolean seserviceconnected; private button button; @override protected void oncreate(bundle savedinstancestate) { final string log_tag = "hellosmartcard"; seek { log.i(log_tag, "creating seservice object"); this.seserviceconnected = false; seservice = new seservice(mainactivity.this, mainactivity.this); } grab (securityexception e) { log.e(log_tag, "binding not allowed, uses-permission org.simalliance.openmobileapi.smartcard?"); } grab (exception e) { log.e(log_tag, "exception: " + e.getmessage()); } super.oncreate(savedinstancestate); linearlayout layout = new linearlayout(this); layout.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); button = new button(this); button.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); button.settext("click me"); button.setenabled(false); button.setonclicklistener(new onclicklistener() { public void onclick(view v) { seek { log.i(log_tag, "retrieve available readers..."); reader[] readers = seservice.getreaders(); if (readers.length < 1) return; uuicreader = null; (reader reader : readers) { if (reader.getname().equalsignorecase("sim - uicc")) { uuicreader = reader; break; } } log.i(log_tag, "create session uicc reader..."); session session = uuicreader.opensession(); log.i(log_tag, "create logical channel within session..."); channel channel = session.openlogicalchannel( new byte[] { (byte) 0xf9, (byte) 0xf4, (byte) 0x0f, (byte) 0x65, (byte) 0x18, (byte) 0xc9, (byte) 0x54, (byte) 0x1e, (byte) 0xcd, (byte) 0xad } ); log.d(log_tag, "send helloworld apdu command"); byte[] respapdu = channel.transmit(new byte[] { (byte) 0x90, 0x10, 0x00, 0x00, 0x00 }); channel.close(); // parse response apdu , show text remove sw1 sw2 // first byte[] hellostr = new byte[respapdu.length - 2]; system.arraycopy(respapdu, 0, hellostr, 0, respapdu.length - 2); toast.maketext(mainactivity.this, new string(hellostr), toast.length_long).show(); } grab (exception e) { log.e(log_tag, "error occured:", e); return; } } }); layout.addview(button); setcontentview(layout); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); homecoming true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); if (id == r.id.action_settings) { homecoming true; } homecoming super.onoptionsitemselected(item); } @override public void serviceconnected(seservice arg0) { log.i("seservice", "connected"); this.seserviceconnected = this.seservice.isconnected(); updatebuttonstatus(button, this.seserviceconnected); } private void updatebuttonstatus(button button, boolean enabled) { button.setenabled(enabled); } @override protected void ondestroy() { if (seservice != null && seservice.isconnected()) { seservice.shutdown(); this.seserviceconnected = false; updatebuttonstatus(button, this.seserviceconnected); } super.ondestroy(); } }

i believe don't have set right on sim card regarding applet access, since part not domain, don't know prepare this.

i've ran give-and-take on google groups sound similar predicament, i'm not sure how interpret it.

any help appreciated!

the error

java.lang.securityexception: access command enforcer: access denied: ef_dir not found!!

is quite clear. open mobiel api implementation on s3's stock firmware requires pkcs#15 file construction (access command file system, arf) nowadays on secure element (uicc). (instead of access command applet (ara) introduced globalplatform secure element access command specification.)

so need file scheme looks (see illustration , see globalplatform secure element access command specification farther reference) nowadays on uicc:

mf (3f00) |- ef dir (2f00) --> shall reference pkcs-15 | |- df pkcs-15 | |- odf --> shall reference dodf |- dodf --> shall reference ef acmain |- ef acmain --> shall reference ef acrules |- ef acrules --> shall reference ef acconditions files |- ef acconditions1 |- ...

java android galaxy open-mobile-api

No comments:

Post a Comment