laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/android-apdu-proxy/+/41804?usp=email )

Change subject: OmapiCallbackHandlerVpcd: fetch SELECT response from OMAPI
......................................................................

OmapiCallbackHandlerVpcd: fetch SELECT response from OMAPI

At the moment we get the select response by selecting 7FFF, which
is an alias for the currently selected application. This returns a
select response when an ISIM or USIM application is selected. Other
applications may react differently here.

OMAPI has a getSelectResponse method through which we can get the
actual response that was received from the card when the application
was selected when openLogicalChannel was called. This is far more
accurate, so lets use getSelectResponse instead of selecting 7FFF.

Change-Id: Iacbc907ef157f20bed88325fcf6b58717990005a
---
M app/src/main/java/org/osmocom/androidApduProxy/Omapi.java
M app/src/main/java/org/osmocom/androidApduProxy/OmapiCallbackHandlerVpcd.java
2 files changed, 23 insertions(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/app/src/main/java/org/osmocom/androidApduProxy/Omapi.java 
b/app/src/main/java/org/osmocom/androidApduProxy/Omapi.java
index afd4515..1ee173c 100644
--- a/app/src/main/java/org/osmocom/androidApduProxy/Omapi.java
+++ b/app/src/main/java/org/osmocom/androidApduProxy/Omapi.java
@@ -192,6 +192,28 @@
     }

     /**
+     * Read the SELECT response after method open was called successfully.
+     * @param channelId id-number of the OMAPI Channel
+     * @return array of bytes that contains the SELECT response or, throws 
Exception on error
+     */
+    public byte[] getSelRes(int channelId) throws Exception {
+        try {
+            ensureSeService();
+            if (!channels.containsKey(channelId))
+                throw new Exception(String.format("no channel open under 
channelId = %d", channelId));
+            Channel channel = channels.get(channelId);
+            byte[] response = channel.getSelectResponse();
+            if (response == null)
+                throw new Exception("unresponsive card!");
+            Log.d("OMAPI", "SELECT RESPONSE: " + Utils.b2h(response) + "\n");
+            return response;
+        } catch (Exception e) {
+            Log.e("OMAPI", e.getMessage() + "\n");
+            throw e;
+        }
+    }
+
+    /**
      * Perform an APDU transaction on the card.
      * @param channelId id-number of the OMAPI Channel
      * @param apdu array of bytes that contains the command APDU (to card)
diff --git 
a/app/src/main/java/org/osmocom/androidApduProxy/OmapiCallbackHandlerVpcd.java 
b/app/src/main/java/org/osmocom/androidApduProxy/OmapiCallbackHandlerVpcd.java
index 56db37f..9d1ebb9 100644
--- 
a/app/src/main/java/org/osmocom/androidApduProxy/OmapiCallbackHandlerVpcd.java
+++ 
b/app/src/main/java/org/osmocom/androidApduProxy/OmapiCallbackHandlerVpcd.java
@@ -163,7 +163,7 @@
                             int newOmapiChannel;
                             byte[] response;
                             newOmapiChannel = omapi.open(omapiReader, aidReq);
-                            response = omapi.transact(newOmapiChannel, 
Utils.h2b("00a40004027fff"));
+                            response = omapi.getSelRes(newOmapiChannel);
                             Log.i("PROXY", String.format("Opening new channel 
(%d) for AID (%s) was successful, now closing the old channel (%d)...\n",
                                     newOmapiChannel, Utils.b2h(aidReq), 
omapiChannel));
                             omapi.close(omapiChannel);

--
To view, visit https://gerrit.osmocom.org/c/android-apdu-proxy/+/41804?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: android-apdu-proxy
Gerrit-Branch: master
Gerrit-Change-Id: Iacbc907ef157f20bed88325fcf6b58717990005a
Gerrit-Change-Number: 41804
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>

Reply via email to