dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/android-apdu-proxy/+/41805?usp=email )
Change subject: OmapiCallbackHandlerVpcd: pass SELECT parameter P2 to OMAPI ......................................................................
OmapiCallbackHandlerVpcd: pass SELECT parameter P2 to OMAPI
The OMAPI method openLogicalChannel may take an optional parameter p2, This parameter. Among other function, this paramter in particular controls how to deal with short DF-Names that match the AIDs of several applications.
Since we always know this parameter from the TPDU that we receive from VPCD, let's pass it on to OMAPI when we create a new channel.
Related OS#6836
Change-Id: Ibab2cc197284e6177a83338007a0b7f77e0ab8b9 --- M app/src/main/java/org/osmocom/androidApduProxy/Omapi.java M app/src/main/java/org/osmocom/androidApduProxy/OmapiCallbackHandlerVpcd.java 2 files changed, 14 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/android-apdu-proxy refs/changes/05/41805/1
diff --git a/app/src/main/java/org/osmocom/androidApduProxy/Omapi.java b/app/src/main/java/org/osmocom/androidApduProxy/Omapi.java index 6d88273..c814a0e 100644 --- a/app/src/main/java/org/osmocom/androidApduProxy/Omapi.java +++ b/app/src/main/java/org/osmocom/androidApduProxy/Omapi.java @@ -170,13 +170,14 @@ * Open a channel on the specified reader to the specified AID. * @param readerName string that contains the reader name (e.g. "SIM1") * @param aid array of bytes that contains the AID of the application to access + * @param p2 parameter value to use with the SELECT APDU * @return OMAPI Channel number on success, throws Exception on error */ - public int open(String readerName, byte[] aid) throws Exception { + public int open(String readerName, byte[] aid, byte p2) throws Exception { try { ensureSeService(); Session session = getOrCreateSession(readerName); - Channel channel = session.openLogicalChannel(aid); + Channel channel = session.openLogicalChannel(aid, p2); if (channel == null) throw new Exception(String.format("could not open channel for AID (%s) on reader: %s!\n", Utils.b2h(aid), readerName)); @@ -192,6 +193,16 @@ }
/** + * Open a channel on the specified reader to the specified AID. + * @param readerName string that contains the reader name (e.g. "SIM1") + * @param aid array of bytes that contains the AID of the application to access + * @return OMAPI Channel number on success, throws Exception on error + */ + public int open(String readerName, byte[] aid) throws Exception { + return open(readerName, aid, (byte)0x04); + } + + /** * 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 diff --git a/app/src/main/java/org/osmocom/androidApduProxy/OmapiCallbackHandlerVpcd.java b/app/src/main/java/org/osmocom/androidApduProxy/OmapiCallbackHandlerVpcd.java index 8bb41ac..d82a23a 100644 --- a/app/src/main/java/org/osmocom/androidApduProxy/OmapiCallbackHandlerVpcd.java +++ b/app/src/main/java/org/osmocom/androidApduProxy/OmapiCallbackHandlerVpcd.java @@ -162,7 +162,7 @@ try { int newOmapiChannel; byte[] response; - newOmapiChannel = omapi.open(omapiReader, aidReq); + newOmapiChannel = omapi.open(omapiReader, aidReq, tpdu[3]); 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));