Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader for OMNI RING #9

Open
laurabilius opened this issue Nov 18, 2020 · 22 comments
Open

Reader for OMNI RING #9

laurabilius opened this issue Nov 18, 2020 · 22 comments

Comments

@laurabilius
Copy link

Hello,

I have the OMNI ring I want to ask if it is possible to delete the applet and loading applets using the reader from an android smartphone? For example, my smartphone recognizes the ring (Type B). Exist an .apk that works with OMNI?

If it's not possible, I want to ask why ACR122U can brick the ring, and what reader you recommend?
Is ACR1251U ok?
Thank you!

@benbenbenbenbenben
Copy link
Collaborator

There is a app called "Smart Card Reader" on F-Droid that supposedly let's you use your phone a reader over IP to your computer. I could never get it to work but it is worth exploring.

Also, there is a code sample that builds a cordova app with smartcard access that might be a starting point: https://github.com/dcdc-io/node-gp-phonegap - it doesn't do app installs but that's only because it doesn't have the commands to do it written in there yet.

On other reader hardware, I'll check when I'm back in the office what models I have used.

@laurabilius
Copy link
Author

Thank you. I tried the Smart card reader, but I did 't find yet an available vpcd software for host. I' ll keep searching.

But thank you!

@benbenbenbenbenben
Copy link
Collaborator

benbenbenbenbenben commented Nov 26, 2020

So my reader on my desk is a HID OMNIKEY 5422 and it hasn't had any issues with any rings. I've abused them quite a lot and not bricked one yet, so I'd recommend it.

I'm still planning to make a working example using node-gp to write a ring via a smartphone but unfortuanately I have a lot of other projects to clear first.

Tha said, I wrote node-gp so if you do want to start working on something smartphone enabled with node-gp I'll happily answer technical questions about it in the meantime.

@benbenbenbenbenben
Copy link
Collaborator

benbenbenbenbenben commented Nov 26, 2020

Okay, update.

Here is a barely tested version of code that will write an applet from a phone:

https://github.com/dcdc-io/node-gp-phonegap/tree/dev-auto-install-ndef-tag

To build this on a new Windows 10 machine last night, I had to:

And finally to run it:

  • run cordova run android --device

As ever with Cordova, you can debug in Chrome at chrome://inspect on a USB connected desktop.

In this example, when a device is presented it will automatically install the famed NDEF tag applet, turning your ring into an writable NDEF tag.

note: If you already have an NDEF tag installed, you will get a 6985 response.


edit: linked is the section of code that installs the applet

https://github.com/dcdc-io/node-gp-phonegap/blob/aa1b6e62b4a041bb51a222d551440d008d3e21d9/src/index.js#L47

@JohnMcLear
Copy link
Contributor

Worth noting I think Cordova is dead so you might wanna migrate

@benbenbenbenbenben
Copy link
Collaborator

benbenbenbenbenben commented Nov 26, 2020

Worth noting I think Cordova is dead so you might wanna migrate

I thought bad things happened to PhoneGap but Cordova lives on? Source?

https://chrisgriffith.wordpress.com/2020/08/14/phonegap-is-dead-long-live-cordova/

@laurabilius
Copy link
Author

Yes, Cordova was updated in August 2020, according to https://cordova.apache.org/announcements/2020/08/04/cordova-cli-release-10.0.0.html

@laurabilius
Copy link
Author

Okay, update.

Here is a barely tested version of code that will write an applet from a phone:

https://github.com/dcdc-io/node-gp-phonegap/tree/dev-auto-install-ndef-tag

To build this on a new Windows 10 machine last night, I had to:

  • install Cordova
  • install Android Studio
  • install Gradle
  • run cordova platform add android
  • run cordova plugin add phonegap-nfc
  • delete line 39~ of /plugins/phongap-nfc/plugin.xml (as per chariotsolutions/phonegap-nfc#371)
  • run cordova plugin add phonegap-nfc (again)
  • run cordova build

And finally to run it:

  • run cordova run android --device

As ever with Cordova, you can debug in Chrome at chrome://inspect on a USB connected desktop.

In this example, when a device is presented it will automatically install the famed NDEF tag applet, turning your ring into an writable NDEF tag.

note: If you already have an NDEF tag installed, you will get a 6985 response.

edit: linked is the section of code that installs the applet

https://github.com/dcdc-io/node-gp-phonegap/blob/aa1b6e62b4a041bb51a222d551440d008d3e21d9/src/index.js#L47

I will follow the recommendations you offered. I'll let you know how it goes.

Thank you very much for your effort!

@laurabilius
Copy link
Author

There is a app called "Smart Card Reader" on F-Droid that supposedly let's you use your phone a reader over IP to your computer. I could never get it to work but it is worth exploring.

Also, there is a code sample that builds a cordova app with smartcard access that might be a starting point: https://github.com/dcdc-io/node-gp-phonegap - it doesn't do app installs but that's only because it doesn't have the commands to do it written in there yet.

On other reader hardware, I'll check when I'm back in the office what models I have used.

I tried the Smart card reader, but I had troubles concerning vpcd.exe, such as missing .dll files from sys. So I didn't get too far, but it remains an open "gate".

@JohnMcLear
Copy link
Contributor

It lives on but it seems like it's days are numbered. Sadly ;(.

Please convince me otherwise!!

@laurabilius
Copy link
Author

Hello,

I m coming with an error on cordova build android --device.

'Using Android SDK: C:\adt-bundle-windows-x86_64-20131030\sdk
Subproject Path: CordovaLib
Subproject Path: app

FAILURE: Build failed with an exception.

  • Where:
    Build file 'C:\cordovaprj\node-gp-phonegap\platforms\android\app\build.gradle' line: 256

  • What went wrong:
    A problem occurred evaluating project ':app'.

Invalid revision: 30.0.0-preview

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s
Command failed with exit code 1: C:\cordovaprj\node-gp-phonegap\platforms\android\gradlew cdvBuildDebug -b C:\cordovaprj\node-gp-phonegap\platforms\android\build.gradle'

Can you give an advice to solve this problem. Thank you very much!

@benbenbenbenbenben
Copy link
Collaborator

I'm not at the computer but a guess is going to that my Android SDK was API version 30 when I pushed that.

Did you the the SDK Manager feature of Android Studio to install SDKs?

@laurabilius
Copy link
Author

Hello, I succeed in installing HelloCordova.apk on my smartphone (Android 10). I uninstalled and installed again the packages from the SDK manager (not from ANDROID STUDIO) and confirmed the licenses. It worked from the first run.

The question is what should I do next, to delete the applet from the Omni ring? Maybe I should do something extra.

Sorry for bothering you so much. Thanks!

@laurabilius
Copy link
Author

Update: Maybe I'm doing something wrong, i ran GP and I get the error The Smart card resource manager is not running.

@benbenbenbenbenben
Copy link
Collaborator

Where are you seeing that error?

I don't remember if I tested deleting with node-gp before now, but it's reasonable to expect it to work as it's just another command. I know it can install applets and list them.

@laurabilius
Copy link
Author

laurabilius commented Dec 3, 2020

I ran gp.exe on cmd.
But like I said, maybe I didn't understand something properly

C:\cordovaprj\node-gp-phonegap>gp.exe --list
Exception in thread "main" jnasmartcardio.Smartcardio$EstablishContextException: jnasmartcardio.Smartcardio$JnaPCSCException: SCardEstablishContext got response 0x8010001d (SCARD_E_NO_SERVICE: The Smart card resource manager is not running.)
        at jnasmartcardio.Smartcardio$JnaTerminalFactorySpi.engineTerminals(Smartcardio.java:81)
        at javax.smartcardio.TerminalFactory.terminals(Unknown Source)
        at pro.javacard.gp.GPTool.main(GPTool.java:123)
Caused by: jnasmartcardio.Smartcardio$JnaPCSCException: SCardEstablishContext got response 0x8010001d (SCARD_E_NO_SERVICE: The Smart card resource manager is not running.)
        at jnasmartcardio.Smartcardio.check(Smartcardio.java:961)
        at jnasmartcardio.Smartcardio.check(Smartcardio.java:952)
        at jnasmartcardio.Smartcardio.access$000(Smartcardio.java:34)
        at jnasmartcardio.Smartcardio$JnaTerminalFactorySpi.engineTerminals(Smartcardio.java:79)
        ... 2 more

@benbenbenbenbenben
Copy link
Collaborator

benbenbenbenbenben commented Dec 3, 2020

That gp.exe is Martin Paljak's original work and it won't communicate with a your ring unless you have a "traditional" reader attached. For gp.exe to work in a scenario where you can use you phone as a reader will require more work. Specifically creating a OS SC driver that connects over IP/HTTP.

What you should do instead is use node-gp to list/delete/install directly from your cordova app. Using the demo code I linked previously, the API's you'll use are:

gpcard.getApplets, gpcard.getPackages
gpcard.deletePackage
gpcard.installAuto

Look at this link so see how all but deletePackage are already used. See lines 52, 98, and 99:

https://github.com/dcdc-io/node-gp-phonegap/blob/aa1b6e62b4a041bb51a222d551440d008d3e21d9/src/index.js

edit: a practical pattern to use would be to:

  1. Ask the user to "touch" the ring to list the installed contents (the handleConnected method is fired when they touch)
  2. Ask the user to select a package from the above results for deletion (as in remember what selection they made)
  3. Ask the user to "touch" to delete (by calling deletePackage(userSelection) within handleConnected

@laurabilius
Copy link
Author

laurabilius commented Dec 3, 2020

I am at my first app concerning smart rings and NFC. I am trying to understand how it works, but now I've clarified a lot of things and it doesn't seem that hard.

I understood why GP isn't working for me. Makes sense.
I'll study more about GlobalPlatform.

I have a question: doTestInstall which is called in handleConnected makes the important work, delete and install a new applet. According to https://github.com/dcdc-io/node-gp-phonegap/blob/aa1b6e62b4a041bb51a222d551440d008d3e21d9/src/index.js it loads a .cap file. I tried to open it, but I couldn't see what's in there. Suppose this file is generated by the app? (I searched on the internet about .cap files).

I downloaded the .cap file (to see what is happening/ curiosity) and run it and it gives me the error on the app: Tag was lost.

So, what's the .cap file exactly in this situation?

Thank you!

@benbenbenbenbenben
Copy link
Collaborator

cap files are compiled applets that are produced when compiling java applets for smartcard targets. To create applets you need something like JCIDE and a JavaCard SDK.

There are some quirks with the version of the SDK your ring supports that I plan to write about in the future. I'm currently snowed under with other client work so I can't tell you all the details right now.

Of the top of my head you want to get JCIDE and use the JavaCard SDK 3.05 or 3.04

@laurabilius
Copy link
Author

Ok. I'll try to create a "hello world" applet, hope I will face no problems.

Thank you for the guidelines. I appreciate.

@laurabilius
Copy link
Author

laurabilius commented Jan 15, 2021

Hello again. Thank you very much for giving me the information. I finally succeeded to delete the applet and to convert the ring into writable.

Is there any possibility to increase the memory over short range?
Thank you!

@benbenbenbenbenben
Copy link
Collaborator

Hello again. Thank you very much for giving me the information. I finally succeeded to delete the applet and to convert the ring into writable.

Is there any possibility to increase the memory over short range?
Thank you!

Yes but you'd have to experiment with the applet source code to find out what the largest practical/reliable payload size is for OMNI ring.

I believe the NDEF limit is 4GB~ which is well beyond what you'll do with OMNI ring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants