OpenSC / OpenSC

Open source smart card tools and middleware. PKCS#11/MiniDriver/Tokend
https://github.com/OpenSC/OpenSC/wiki
GNU Lesser General Public License v2.1
2.57k stars 733 forks source link

PCSC Service Support on Android with OpenSC #3214

Open flyingsaucer88 opened 3 months ago

flyingsaucer88 commented 3 months ago

Hello,

We are trying to build OpenSC on Android and have tried to follow the solution given on this page:

https://github.com/OpenSC/OpenSC/issues/2480

However, it looks like we are missing the underlying Android PCSC support.

Has anyone been able to figure that out? @dengert

frankmorgner commented 3 months ago

Option 1: Create a shared library which takes the PC/SC requests and forward them via JNI to you Anrdoid (NFC) app. Option 2: Take an existing implementation of libpcsclite.so, which forwards PC/SC requests via some other shared interface, e.g. vpcd that forwards this via a network socket. In you Android (NFC) app, uce this IPC mechanism to respond to the request.

flyingsaucer88 commented 3 months ago

Dear Frank,

Thank you for your suggestions.

We are using the USB OTG connection and not the USB NFC connection. Will anything you suggested change based on that information?

@frankmorgner

frankmorgner commented 3 months ago

Speaking of USB OTG, I assume that you want to use the phone (app) as reader, so you are not connecting an external PC/SC reader to the phone, correct?

flyingsaucer88 commented 3 months ago

@frankmorgner

No,

I am using a phone but to keep things scalable I want to connect an external PCSC reader (since not all phones have NFC right now and I don't have an Android NFC phone) to the phone via the USB OTG. The OpenSC should run on the Android phone and will communicate with the reader over USB. I believe I need a PCSC service to run in the background at the OS level.

Correct me if I am wrong.

frankmorgner commented 3 months ago

I that case, you could use https://seek-for-android.github.io/ which implements a complete PC/SC stack (PCSC-Lite) on Android.

If your targetting OpenSC only, I suggest you try OpenCT with its own more lightweight implementation for accessing a USB CCID smart card reader. There are also some other implementations around for accessing the reader directly, for example in sc-hsm-embedded

flyingsaucer88 commented 3 months ago

Hi @frankmorgner

We did look at Seek for Android and looks like that has been taken off github. If you are aware of the presence of Seek for Android anywhere else in the public domain please advise.

We will look into OpenCT and insc-hsm-embedded. We were unaware of their existence.